77#include < imgui.h>
88#include < imgui_internal.h>
99
10+ #include " OvUI/Internal/TextureID.h"
1011#include " OvUI/Widgets/Layout/GroupCollapsable.h"
1112
1213OvUI::Widgets::Layout::GroupCollapsable::GroupCollapsable (const std::string & p_name) :
@@ -22,7 +23,7 @@ void OvUI::Widgets::Layout::GroupCollapsable::_Draw_Impl()
2223
2324 EndDisableOverride (); // Early end disable override group so that children are not affected
2425
25- if (reorderable)
26+ if (reorderable || !actions. empty () )
2627 {
2728 const ImVec2 headerMin = ImGui::GetItemRectMin ();
2829 const ImVec2 headerMax = ImGui::GetItemRectMax ();
@@ -32,22 +33,40 @@ void OvUI::Widgets::Layout::GroupCollapsable::_Draw_Impl()
3233
3334 // Keep original vertical padding so arrow buttons fill the header height exactly
3435 const float padY = ImGui::GetStyle ().FramePadding .y ;
35- ImGui::PushStyleVar (ImGuiStyleVar_FramePadding, ImVec2{0 , padY});
36+ ImGui::PushStyleVar (ImGuiStyleVar_FramePadding, ImVec2{padY , padY});
3637 ImGui::PushStyleColor (ImGuiCol_Button, ImVec4{0 , 0 , 0 , 0 });
3738 ImGui::PushStyleColor (ImGuiCol_ButtonHovered, ImGui::GetStyleColorVec4 (ImGuiCol_HeaderHovered));
3839 ImGui::PushStyleColor (ImGuiCol_ButtonActive, ImGui::GetStyleColorVec4 (ImGuiCol_HeaderActive));
3940
40- ImGui::SetCursorScreenPos ({rightEdge - bSize * 2 .0f , headerMin.y });
41- if (!canMoveUp) ImGui::BeginDisabled ();
42- if (ImGui::ArrowButton ((" ##mu" + m_widgetID).c_str (), ImGuiDir_Up))
43- MoveUpEvent.Invoke ();
44- if (!canMoveUp) ImGui::EndDisabled ();
41+ if (reorderable)
42+ {
43+ ImGui::SetCursorScreenPos ({rightEdge - bSize * 2 .0f , headerMin.y });
44+ if (!canMoveUp) ImGui::BeginDisabled ();
45+ if (ImGui::ArrowButton ((" ##mu" + m_widgetID).c_str (), ImGuiDir_Up))
46+ MoveUpEvent.Invoke ();
47+ if (!canMoveUp) ImGui::EndDisabled ();
4548
46- ImGui::SetCursorScreenPos ({rightEdge - bSize, headerMin.y });
47- if (!canMoveDown) ImGui::BeginDisabled ();
48- if (ImGui::ArrowButton ((" ##md" + m_widgetID).c_str (), ImGuiDir_Down))
49- MoveDownEvent.Invoke ();
50- if (!canMoveDown) ImGui::EndDisabled ();
49+ ImGui::SetCursorScreenPos ({rightEdge - bSize, headerMin.y });
50+ if (!canMoveDown) ImGui::BeginDisabled ();
51+ if (ImGui::ArrowButton ((" ##md" + m_widgetID).c_str (), ImGuiDir_Down))
52+ MoveDownEvent.Invoke ();
53+ if (!canMoveDown) ImGui::EndDisabled ();
54+ }
55+
56+ const float actionsRight = rightEdge - (reorderable ? 2 .0f * bSize : 0 .0f );
57+ for (int i = static_cast <int >(actions.size ()) - 1 ; i >= 0 ; --i)
58+ {
59+ ImGui::SetCursorScreenPos ({actionsRight - static_cast <float >(actions.size () - i) * bSize, headerMin.y });
60+ Internal::TextureID texID;
61+ texID.id = actions[i].textureID ;
62+ if (ImGui::ImageButtonEx (
63+ ImGui::GetID ((" ##act" + std::to_string (i) + m_widgetID).c_str ()),
64+ texID.id ,
65+ {bSize - 2 .0f * padY, bSize - 2 .0f * padY},
66+ {0 .f , 1 .f }, {1 .f , 0 .f },
67+ {0 , 0 , 0 , 0 }, {1 , 1 , 1 , 1 }))
68+ actions[i].callback ();
69+ }
5170
5271 ImGui::PopStyleColor (3 );
5372 ImGui::PopStyleVar ();
0 commit comments