|
@@ -1,4 +1,4 @@
|
|
-// dear imgui, v1.91.0
|
|
|
|
|
|
+// dear imgui, v1.91.1 WIP
|
|
// (widgets code)
|
|
// (widgets code)
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -6482,6 +6482,10 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
|
const float arrow_hit_x2 = (text_pos.x - text_offset_x) + (g.FontSize + padding.x * 2.0f) + style.TouchExtraPadding.x;
|
|
const float arrow_hit_x2 = (text_pos.x - text_offset_x) + (g.FontSize + padding.x * 2.0f) + style.TouchExtraPadding.x;
|
|
const bool is_mouse_x_over_arrow = (g.IO.MousePos.x >= arrow_hit_x1 && g.IO.MousePos.x < arrow_hit_x2);
|
|
const bool is_mouse_x_over_arrow = (g.IO.MousePos.x >= arrow_hit_x1 && g.IO.MousePos.x < arrow_hit_x2);
|
|
|
|
|
|
|
|
+ const bool is_multi_select = (g.LastItemData.InFlags & ImGuiItemFlags_IsMultiSelect) != 0;
|
|
|
|
+ if (is_multi_select) // We absolutely need to distinguish open vs select so _OpenOnArrow comes by default
|
|
|
|
+ flags |= (flags & ImGuiTreeNodeFlags_OpenOnMask_) == 0 ? ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick : ImGuiTreeNodeFlags_OpenOnArrow;
|
|
|
|
+
|
|
// Open behaviors can be altered with the _OpenOnArrow and _OnOnDoubleClick flags.
|
|
// Open behaviors can be altered with the _OpenOnArrow and _OnOnDoubleClick flags.
|
|
// Some alteration have subtle effects (e.g. toggle on MouseUp vs MouseDown events) due to requirements for multi-selection and drag and drop support.
|
|
// Some alteration have subtle effects (e.g. toggle on MouseUp vs MouseDown events) due to requirements for multi-selection and drag and drop support.
|
|
// - Single-click on label = Toggle on MouseUp (default, when _OpenOnArrow=0)
|
|
// - Single-click on label = Toggle on MouseUp (default, when _OpenOnArrow=0)
|
|
@@ -6502,16 +6506,12 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
|
const bool was_selected = selected;
|
|
const bool was_selected = selected;
|
|
|
|
|
|
// Multi-selection support (header)
|
|
// Multi-selection support (header)
|
|
- const bool is_multi_select = (g.LastItemData.InFlags & ImGuiItemFlags_IsMultiSelect) != 0;
|
|
|
|
if (is_multi_select)
|
|
if (is_multi_select)
|
|
{
|
|
{
|
|
// Handle multi-select + alter button flags for it
|
|
// Handle multi-select + alter button flags for it
|
|
MultiSelectItemHeader(id, &selected, &button_flags);
|
|
MultiSelectItemHeader(id, &selected, &button_flags);
|
|
if (is_mouse_x_over_arrow)
|
|
if (is_mouse_x_over_arrow)
|
|
button_flags = (button_flags | ImGuiButtonFlags_PressedOnClick) & ~ImGuiButtonFlags_PressedOnClickRelease;
|
|
button_flags = (button_flags | ImGuiButtonFlags_PressedOnClick) & ~ImGuiButtonFlags_PressedOnClickRelease;
|
|
-
|
|
|
|
- // We absolutely need to distinguish open vs select so comes by default
|
|
|
|
- flags |= ImGuiTreeNodeFlags_OpenOnArrow;
|
|
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -6526,18 +6526,20 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
|
{
|
|
{
|
|
if (pressed && g.DragDropHoldJustPressedId != id)
|
|
if (pressed && g.DragDropHoldJustPressedId != id)
|
|
{
|
|
{
|
|
- if ((flags & (ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick)) == 0 || (g.NavActivateId == id && !is_multi_select))
|
|
|
|
- toggled = true;
|
|
|
|
|
|
+ if ((flags & ImGuiTreeNodeFlags_OpenOnMask_) == 0 || (g.NavActivateId == id && !is_multi_select))
|
|
|
|
+ toggled = true; // Single click
|
|
if (flags & ImGuiTreeNodeFlags_OpenOnArrow)
|
|
if (flags & ImGuiTreeNodeFlags_OpenOnArrow)
|
|
toggled |= is_mouse_x_over_arrow && !g.NavDisableMouseHover; // Lightweight equivalent of IsMouseHoveringRect() since ButtonBehavior() already did the job
|
|
toggled |= is_mouse_x_over_arrow && !g.NavDisableMouseHover; // Lightweight equivalent of IsMouseHoveringRect() since ButtonBehavior() already did the job
|
|
if ((flags & ImGuiTreeNodeFlags_OpenOnDoubleClick) && g.IO.MouseClickedCount[0] == 2)
|
|
if ((flags & ImGuiTreeNodeFlags_OpenOnDoubleClick) && g.IO.MouseClickedCount[0] == 2)
|
|
- toggled = true;
|
|
|
|
|
|
+ toggled = true; // Double click
|
|
}
|
|
}
|
|
else if (pressed && g.DragDropHoldJustPressedId == id)
|
|
else if (pressed && g.DragDropHoldJustPressedId == id)
|
|
{
|
|
{
|
|
IM_ASSERT(button_flags & ImGuiButtonFlags_PressedOnDragDropHold);
|
|
IM_ASSERT(button_flags & ImGuiButtonFlags_PressedOnDragDropHold);
|
|
if (!is_open) // When using Drag and Drop "hold to open" we keep the node highlighted after opening, but never close it again.
|
|
if (!is_open) // When using Drag and Drop "hold to open" we keep the node highlighted after opening, but never close it again.
|
|
toggled = true;
|
|
toggled = true;
|
|
|
|
+ else
|
|
|
|
+ pressed = false; // Cancel press so it doesn't trigger selection.
|
|
}
|
|
}
|
|
|
|
|
|
if (g.NavId == id && g.NavMoveDir == ImGuiDir_Left && is_open)
|
|
if (g.NavId == id && g.NavMoveDir == ImGuiDir_Left && is_open)
|