mirror of
https://github.com/xemu-project/imgui.git
synced 2024-11-27 04:00:22 +00:00
Internals: Selectable: Renamed variables. Todo update.
This commit is contained in:
parent
f843facba4
commit
7fd9199a1d
2
TODO.txt
2
TODO.txt
@ -215,6 +215,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
||||
- filters: handle wildcards (with implicit leading/trailing *), regexps
|
||||
- filters: fuzzy matches (may use code at blog.forrestthewoods.com/4cffeed33fdb)
|
||||
|
||||
- drag and drop: allow drag target to alter tooltip / and or disable tooltip.
|
||||
- drag and drop: add demo. (#143, #479)
|
||||
- drag and drop: allow using with other mouse buttons (where activeid won't be set). (#1637)
|
||||
- drag and drop: test with reordering nodes (in a list, or a tree node). (#143)
|
||||
@ -296,6 +297,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
||||
- demo: demonstration Plot offset
|
||||
- examples: window minimize, maximize (#583)
|
||||
- examples: provide a zero-framerate/idle example.
|
||||
- examples: apple: apple_example should be using modern GL3.
|
||||
- examples: glfw: could go idle when minimized? if (glfwGetWindowAttrib(window, GLFW_ICONIFIED)) { glfwWaitEvents(); continue; } // issue: DeltaTime will be super high on resume, perhaps provide a way to let impl know (#440)
|
||||
- optimization: replace vsnprintf with stb_printf? or enable the defines/infrastructure to allow it (#1038)
|
||||
- optimization: add clipping for multi-component widgets (SliderFloatX, ColorEditX, etc.). one problem is that nav branch can't easily clip parent group when there is a move request.
|
||||
|
28
imgui.cpp
28
imgui.cpp
@ -11221,28 +11221,28 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
|
||||
ImVec2 size(size_arg.x != 0.0f ? size_arg.x : label_size.x, size_arg.y != 0.0f ? size_arg.y : label_size.y);
|
||||
ImVec2 pos = window->DC.CursorPos;
|
||||
pos.y += window->DC.CurrentLineTextBaseOffset;
|
||||
ImRect bb(pos, pos + size);
|
||||
ItemSize(bb);
|
||||
ImRect bb_inner(pos, pos + size);
|
||||
ItemSize(bb_inner);
|
||||
|
||||
// Fill horizontal space.
|
||||
ImVec2 window_padding = window->WindowPadding;
|
||||
float max_x = (flags & ImGuiSelectableFlags_SpanAllColumns) ? GetWindowContentRegionMax().x : GetContentRegionMax().x;
|
||||
float w_draw = ImMax(label_size.x, window->Pos.x + max_x - window_padding.x - window->DC.CursorPos.x);
|
||||
ImVec2 size_draw((size_arg.x != 0 && !(flags & ImGuiSelectableFlags_DrawFillAvailWidth)) ? size_arg.x : w_draw, size_arg.y != 0.0f ? size_arg.y : size.y);
|
||||
ImRect bb_with_spacing(pos, pos + size_draw);
|
||||
ImRect bb(pos, pos + size_draw);
|
||||
if (size_arg.x == 0.0f || (flags & ImGuiSelectableFlags_DrawFillAvailWidth))
|
||||
bb_with_spacing.Max.x += window_padding.x;
|
||||
bb.Max.x += window_padding.x;
|
||||
|
||||
// Selectables are tightly packed together, we extend the box to cover spacing between selectable.
|
||||
float spacing_L = (float)(int)(style.ItemSpacing.x * 0.5f);
|
||||
float spacing_U = (float)(int)(style.ItemSpacing.y * 0.5f);
|
||||
float spacing_R = style.ItemSpacing.x - spacing_L;
|
||||
float spacing_D = style.ItemSpacing.y - spacing_U;
|
||||
bb_with_spacing.Min.x -= spacing_L;
|
||||
bb_with_spacing.Min.y -= spacing_U;
|
||||
bb_with_spacing.Max.x += spacing_R;
|
||||
bb_with_spacing.Max.y += spacing_D;
|
||||
if (!ItemAdd(bb_with_spacing, (flags & ImGuiSelectableFlags_Disabled) ? 0 : id))
|
||||
bb.Min.x -= spacing_L;
|
||||
bb.Min.y -= spacing_U;
|
||||
bb.Max.x += spacing_R;
|
||||
bb.Max.y += spacing_D;
|
||||
if (!ItemAdd(bb, (flags & ImGuiSelectableFlags_Disabled) ? 0 : id))
|
||||
{
|
||||
if ((flags & ImGuiSelectableFlags_SpanAllColumns) && window->DC.ColumnsSet)
|
||||
PushColumnClipRect();
|
||||
@ -11257,7 +11257,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
|
||||
if (flags & ImGuiSelectableFlags_Disabled) button_flags |= ImGuiButtonFlags_Disabled;
|
||||
if (flags & ImGuiSelectableFlags_AllowDoubleClick) button_flags |= ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnDoubleClick;
|
||||
bool hovered, held;
|
||||
bool pressed = ButtonBehavior(bb_with_spacing, id, &hovered, &held, button_flags);
|
||||
bool pressed = ButtonBehavior(bb, id, &hovered, &held, button_flags);
|
||||
if (flags & ImGuiSelectableFlags_Disabled)
|
||||
selected = false;
|
||||
|
||||
@ -11273,18 +11273,18 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
|
||||
if (hovered || selected)
|
||||
{
|
||||
const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_HeaderActive : hovered ? ImGuiCol_HeaderHovered : ImGuiCol_Header);
|
||||
RenderFrame(bb_with_spacing.Min, bb_with_spacing.Max, col, false, 0.0f);
|
||||
RenderNavHighlight(bb_with_spacing, id, ImGuiNavHighlightFlags_TypeThin | ImGuiNavHighlightFlags_NoRounding);
|
||||
RenderFrame(bb.Min, bb.Max, col, false, 0.0f);
|
||||
RenderNavHighlight(bb, id, ImGuiNavHighlightFlags_TypeThin | ImGuiNavHighlightFlags_NoRounding);
|
||||
}
|
||||
|
||||
if ((flags & ImGuiSelectableFlags_SpanAllColumns) && window->DC.ColumnsSet)
|
||||
{
|
||||
PushColumnClipRect();
|
||||
bb_with_spacing.Max.x -= (GetContentRegionMax().x - max_x);
|
||||
bb.Max.x -= (GetContentRegionMax().x - max_x);
|
||||
}
|
||||
|
||||
if (flags & ImGuiSelectableFlags_Disabled) PushStyleColor(ImGuiCol_Text, g.Style.Colors[ImGuiCol_TextDisabled]);
|
||||
RenderTextClipped(bb.Min, bb_with_spacing.Max, label, NULL, &label_size, ImVec2(0.0f,0.0f));
|
||||
RenderTextClipped(bb_inner.Min, bb.Max, label, NULL, &label_size, ImVec2(0.0f,0.0f));
|
||||
if (flags & ImGuiSelectableFlags_Disabled) PopStyleColor();
|
||||
|
||||
// Automatically close popups
|
||||
|
Loading…
Reference in New Issue
Block a user