mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 11:57:00 +00:00
Internals: Tweaks to ItemSize() should be harmless. Added DebugDrawItemRect() helper.
This commit is contained in:
parent
892dfb1dea
commit
a6c3be4bda
16
imgui.cpp
16
imgui.cpp
@ -2969,7 +2969,7 @@ static inline bool IsWindowContentHoverable(ImGuiWindow* window, ImGuiHoveredFla
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Advance cursor given item size for layout.
|
// Advance cursor given item size for layout.
|
||||||
void ImGui::ItemSize(const ImVec2& size, float text_offset_y)
|
void ImGui::ItemSize(const ImVec2& size, float text_baseline_y)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiWindow* window = g.CurrentWindow;
|
ImGuiWindow* window = g.CurrentWindow;
|
||||||
@ -2978,28 +2978,28 @@ void ImGui::ItemSize(const ImVec2& size, float text_offset_y)
|
|||||||
|
|
||||||
// Always align ourselves on pixel boundaries
|
// Always align ourselves on pixel boundaries
|
||||||
const float line_height = ImMax(window->DC.CurrLineSize.y, size.y);
|
const float line_height = ImMax(window->DC.CurrLineSize.y, size.y);
|
||||||
const float text_base_offset = ImMax(window->DC.CurrLineTextBaseOffset, text_offset_y);
|
|
||||||
//if (g.IO.KeyAlt) window->DrawList->AddRect(window->DC.CursorPos, window->DC.CursorPos + ImVec2(size.x, line_height), IM_COL32(255,0,0,200)); // [DEBUG]
|
//if (g.IO.KeyAlt) window->DrawList->AddRect(window->DC.CursorPos, window->DC.CursorPos + ImVec2(size.x, line_height), IM_COL32(255,0,0,200)); // [DEBUG]
|
||||||
window->DC.CursorPosPrevLine.x = window->DC.CursorPos.x + size.x;
|
window->DC.CursorPosPrevLine.x = window->DC.CursorPos.x + size.x;
|
||||||
window->DC.CursorPosPrevLine.y = window->DC.CursorPos.y;
|
window->DC.CursorPosPrevLine.y = window->DC.CursorPos.y;
|
||||||
window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x);
|
window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x); // Next line
|
||||||
window->DC.CursorPos.y = (float)(int)(window->DC.CursorPos.y + line_height + g.Style.ItemSpacing.y);
|
window->DC.CursorPos.y = (float)(int)(window->DC.CursorPos.y + line_height + g.Style.ItemSpacing.y); // Next line
|
||||||
window->DC.CursorMaxPos.x = ImMax(window->DC.CursorMaxPos.x, window->DC.CursorPosPrevLine.x);
|
window->DC.CursorMaxPos.x = ImMax(window->DC.CursorMaxPos.x, window->DC.CursorPosPrevLine.x);
|
||||||
window->DC.CursorMaxPos.y = ImMax(window->DC.CursorMaxPos.y, window->DC.CursorPos.y - g.Style.ItemSpacing.y);
|
window->DC.CursorMaxPos.y = ImMax(window->DC.CursorMaxPos.y, window->DC.CursorPos.y - g.Style.ItemSpacing.y);
|
||||||
//if (g.IO.KeyAlt) window->DrawList->AddCircle(window->DC.CursorMaxPos, 3.0f, IM_COL32(255,0,0,255), 4); // [DEBUG]
|
//if (g.IO.KeyAlt) window->DrawList->AddCircle(window->DC.CursorMaxPos, 3.0f, IM_COL32(255,0,0,255), 4); // [DEBUG]
|
||||||
|
|
||||||
window->DC.PrevLineSize.y = line_height;
|
window->DC.PrevLineSize.y = line_height;
|
||||||
window->DC.PrevLineTextBaseOffset = text_base_offset;
|
window->DC.CurrLineSize.y = 0.0f;
|
||||||
window->DC.CurrLineSize.y = window->DC.CurrLineTextBaseOffset = 0.0f;
|
window->DC.PrevLineTextBaseOffset = ImMax(window->DC.CurrLineTextBaseOffset, text_baseline_y);
|
||||||
|
window->DC.CurrLineTextBaseOffset = 0.0f;
|
||||||
|
|
||||||
// Horizontal layout mode
|
// Horizontal layout mode
|
||||||
if (window->DC.LayoutType == ImGuiLayoutType_Horizontal)
|
if (window->DC.LayoutType == ImGuiLayoutType_Horizontal)
|
||||||
SameLine();
|
SameLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::ItemSize(const ImRect& bb, float text_offset_y)
|
void ImGui::ItemSize(const ImRect& bb, float text_baseline_y)
|
||||||
{
|
{
|
||||||
ItemSize(bb.GetSize(), text_offset_y);
|
ItemSize(bb.GetSize(), text_baseline_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Declare item bounding box for clipping and interaction.
|
// Declare item bounding box for clipping and interaction.
|
||||||
|
@ -383,6 +383,7 @@ enum ImGuiSeparatorFlags_
|
|||||||
// This is going to be exposed in imgui.h when stabilized enough.
|
// This is going to be exposed in imgui.h when stabilized enough.
|
||||||
enum ImGuiItemFlags_
|
enum ImGuiItemFlags_
|
||||||
{
|
{
|
||||||
|
ImGuiItemFlags_None = 0,
|
||||||
ImGuiItemFlags_NoTabStop = 1 << 0, // false
|
ImGuiItemFlags_NoTabStop = 1 << 0, // false
|
||||||
ImGuiItemFlags_ButtonRepeat = 1 << 1, // false // Button() will return true multiple times based on io.KeyRepeatDelay and io.KeyRepeatRate settings.
|
ImGuiItemFlags_ButtonRepeat = 1 << 1, // false // Button() will return true multiple times based on io.KeyRepeatDelay and io.KeyRepeatRate settings.
|
||||||
ImGuiItemFlags_Disabled = 1 << 2, // false // [BETA] Disable interactions but doesn't affect visuals yet. See github.com/ocornut/imgui/issues/211
|
ImGuiItemFlags_Disabled = 1 << 2, // false // [BETA] Disable interactions but doesn't affect visuals yet. See github.com/ocornut/imgui/issues/211
|
||||||
@ -1541,8 +1542,8 @@ namespace ImGui
|
|||||||
IMGUI_API void PushOverrideID(ImGuiID id);
|
IMGUI_API void PushOverrideID(ImGuiID id);
|
||||||
|
|
||||||
// Basic Helpers for widget code
|
// Basic Helpers for widget code
|
||||||
IMGUI_API void ItemSize(const ImVec2& size, float text_offset_y = 0.0f);
|
IMGUI_API void ItemSize(const ImVec2& size, float text_baseline_y = 0.0f);
|
||||||
IMGUI_API void ItemSize(const ImRect& bb, float text_offset_y = 0.0f);
|
IMGUI_API void ItemSize(const ImRect& bb, float text_baseline_y = 0.0f);
|
||||||
IMGUI_API bool ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb = NULL);
|
IMGUI_API bool ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb = NULL);
|
||||||
IMGUI_API bool ItemHoverable(const ImRect& bb, ImGuiID id);
|
IMGUI_API bool ItemHoverable(const ImRect& bb, ImGuiID id);
|
||||||
IMGUI_API bool IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged);
|
IMGUI_API bool IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged);
|
||||||
@ -1704,7 +1705,8 @@ namespace ImGui
|
|||||||
IMGUI_API void ShadeVertsLinearUV(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, bool clamp);
|
IMGUI_API void ShadeVertsLinearUV(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, bool clamp);
|
||||||
|
|
||||||
// Debug Tools
|
// Debug Tools
|
||||||
inline void DebugStartItemPicker() { GImGui->DebugItemPickerActive = true; }
|
inline void DebugDrawItemRect(ImU32 col = IM_COL32(255,0,0,255)) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; GetForegroundDrawList(window)->AddRect(window->DC.LastItemRect.Min, window->DC.LastItemRect.Max, col); }
|
||||||
|
inline void DebugStartItemPicker() { ImGuiContext& g = *GImGui; g.DebugItemPickerActive = true; }
|
||||||
|
|
||||||
} // namespace ImGui
|
} // namespace ImGui
|
||||||
|
|
||||||
|
@ -112,6 +112,7 @@ static ImVec2 InputTextCalcTextSizeW(const ImWchar* text_begin, const
|
|||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// [SECTION] Widgets: Text, etc.
|
// [SECTION] Widgets: Text, etc.
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
// - TextEx() [Internal]
|
||||||
// - TextUnformatted()
|
// - TextUnformatted()
|
||||||
// - Text()
|
// - Text()
|
||||||
// - TextV()
|
// - TextV()
|
||||||
|
Loading…
Reference in New Issue
Block a user