mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Merge branch 'master' into navigation
# Conflicts: # imgui.cpp
This commit is contained in:
commit
938f1b720f
48
imgui.cpp
48
imgui.cpp
@ -3863,31 +3863,39 @@ void ImGui::RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding)
|
||||
}
|
||||
|
||||
// Render a triangle to denote expanded/collapsed state
|
||||
void ImGui::RenderCollapseTriangle(ImVec2 p_min, bool is_open, float scale)
|
||||
void ImGui::RenderTriangle(ImVec2 p_min, ImGuiDir dir, float scale)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
|
||||
const float h = g.FontSize * 1.00f;
|
||||
const float r = h * 0.40f * scale;
|
||||
ImVec2 center = p_min + ImVec2(h*0.50f, h*0.50f*scale);
|
||||
float r = h * 0.40f * scale;
|
||||
ImVec2 center = p_min + ImVec2(h * 0.50f, h * 0.50f * scale);
|
||||
|
||||
ImVec2 a, b, c;
|
||||
if (is_open)
|
||||
switch (dir)
|
||||
{
|
||||
center.y -= r*0.25f;
|
||||
a = center + ImVec2(0,1)*r;
|
||||
b = center + ImVec2(-0.866f,-0.5f)*r;
|
||||
c = center + ImVec2(0.866f,-0.5f)*r;
|
||||
}
|
||||
else
|
||||
{
|
||||
a = center + ImVec2(1,0)*r;
|
||||
b = center + ImVec2(-0.500f,0.866f)*r;
|
||||
c = center + ImVec2(-0.500f,-0.866f)*r;
|
||||
case ImGuiDir_Up:
|
||||
r = -r; // ...fall through, no break!
|
||||
case ImGuiDir_Down:
|
||||
center.y -= r * 0.25f;
|
||||
a = ImVec2(0,1) * r;
|
||||
b = ImVec2(-0.866f,-0.5f) * r;
|
||||
c = ImVec2(+0.866f,-0.5f) * r;
|
||||
break;
|
||||
case ImGuiDir_Left:
|
||||
r = -r; // ...fall through, no break!
|
||||
case ImGuiDir_Right:
|
||||
a = ImVec2(1,0) * r;
|
||||
b = ImVec2(-0.500f,+0.866f) * r;
|
||||
c = ImVec2(-0.500f,-0.866f) * r;
|
||||
break;
|
||||
default:
|
||||
IM_ASSERT(0);
|
||||
break;
|
||||
}
|
||||
|
||||
window->DrawList->AddTriangleFilled(a, b, c, GetColorU32(ImGuiCol_Text));
|
||||
window->DrawList->AddTriangleFilled(center + a, center + b, center + c, GetColorU32(ImGuiCol_Text));
|
||||
}
|
||||
|
||||
void ImGui::RenderBullet(ImVec2 pos)
|
||||
@ -5441,7 +5449,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
if (ButtonBehavior(bb, id, NULL, NULL))
|
||||
window->CollapseToggleWanted = true; // Defer collapsing to next frame as we are too far in the Begin() function
|
||||
RenderNavHighlight(bb, id);
|
||||
RenderCollapseTriangle(window->Pos + style.FramePadding, !window->Collapsed, 1.0f);
|
||||
RenderTriangle(window->Pos + style.FramePadding, window->Collapsed ? ImGuiDir_Right : ImGuiDir_Down, 1.0f);
|
||||
}
|
||||
|
||||
// Close button
|
||||
@ -7282,7 +7290,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
||||
// Framed type
|
||||
RenderFrame(bb.Min, bb.Max, col, true, style.FrameRounding);
|
||||
RenderNavHighlight(bb, id, ImGuiNavHighlightFlags_TypeThin);
|
||||
RenderCollapseTriangle(bb.Min + ImVec2(padding.x, text_base_offset_y), is_open, 1.0f);
|
||||
RenderTriangle(bb.Min + ImVec2(padding.x, text_base_offset_y), is_open ? ImGuiDir_Down : ImGuiDir_Right, 1.0f);
|
||||
if (g.LogEnabled)
|
||||
{
|
||||
// NB: '##' is normally used to hide text (as a library-wide feature), so we need to specify the text range to make sure the ## aren't stripped out here.
|
||||
@ -7308,7 +7316,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
||||
if (flags & ImGuiTreeNodeFlags_Bullet)
|
||||
RenderBullet(bb.Min + ImVec2(text_offset_x * 0.5f, g.FontSize*0.50f + text_base_offset_y));
|
||||
else if (!(flags & ImGuiTreeNodeFlags_Leaf))
|
||||
RenderCollapseTriangle(bb.Min + ImVec2(padding.x, g.FontSize*0.15f + text_base_offset_y), is_open, 0.70f);
|
||||
RenderTriangle(bb.Min + ImVec2(padding.x, g.FontSize*0.15f + text_base_offset_y), is_open ? ImGuiDir_Down : ImGuiDir_Right, 0.70f);
|
||||
if (g.LogEnabled)
|
||||
LogRenderedText(&text_pos, ">");
|
||||
RenderText(text_pos, label, label_end, false);
|
||||
@ -9832,7 +9840,7 @@ bool ImGui::BeginCombo(const char* label, const char* preview_value, ImVec2 popu
|
||||
RenderNavHighlight(frame_bb, id);
|
||||
RenderFrame(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding);
|
||||
RenderFrame(ImVec2(frame_bb.Max.x-arrow_size, frame_bb.Min.y), frame_bb.Max, GetColorU32(popup_open || hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button), true, style.FrameRounding); // FIXME-ROUNDING
|
||||
RenderCollapseTriangle(ImVec2(frame_bb.Max.x - arrow_size + style.FramePadding.y, frame_bb.Min.y + style.FramePadding.y), true);
|
||||
RenderTriangle(ImVec2(frame_bb.Max.x - arrow_size + style.FramePadding.y, frame_bb.Min.y + style.FramePadding.y), ImGuiDir_Down);
|
||||
|
||||
if (preview_value != NULL)
|
||||
RenderTextClipped(frame_bb.Min + style.FramePadding, value_bb.Max, preview_value, NULL, NULL, ImVec2(0.0f,0.0f));
|
||||
@ -10290,7 +10298,7 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
|
||||
float extra_w = ImMax(0.0f, GetContentRegionAvail().x - w);
|
||||
pressed = Selectable(label, menu_is_open, ImGuiSelectableFlags_Menu | ImGuiSelectableFlags_DontClosePopups | ImGuiSelectableFlags_DrawFillAvailWidth | (!enabled ? ImGuiSelectableFlags_Disabled : 0), ImVec2(w, 0.0f));
|
||||
if (!enabled) PushStyleColor(ImGuiCol_Text, g.Style.Colors[ImGuiCol_TextDisabled]);
|
||||
RenderCollapseTriangle(pos + ImVec2(window->MenuColumns.Pos[2] + extra_w + g.FontSize * 0.20f, 0.0f), false);
|
||||
RenderTriangle(pos + ImVec2(window->MenuColumns.Pos[2] + extra_w + g.FontSize * 0.20f, 0.0f), ImGuiDir_Right);
|
||||
if (!enabled) PopStyleColor();
|
||||
}
|
||||
|
||||
|
@ -927,7 +927,7 @@ namespace ImGui
|
||||
IMGUI_API void RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border = true, float rounding = 0.0f);
|
||||
IMGUI_API void RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding = 0.0f);
|
||||
IMGUI_API void RenderColorRectWithAlphaCheckerboard(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, float grid_step, ImVec2 grid_off, float rounding = 0.0f, int rounding_corners_flags = ~0);
|
||||
IMGUI_API void RenderCollapseTriangle(ImVec2 pos, bool is_open, float scale = 1.0f);
|
||||
IMGUI_API void RenderTriangle(ImVec2 pos, ImGuiDir dir, float scale = 1.0f);
|
||||
IMGUI_API void RenderBullet(ImVec2 pos);
|
||||
IMGUI_API void RenderCheckMark(ImVec2 pos, ImU32 col, float sz);
|
||||
IMGUI_API void RenderNavHighlight(const ImRect& bb, ImGuiID id, ImGuiNavHighlightFlags flags = ImGuiNavHighlightFlags_TypeDefault); // Navigation highlight
|
||||
|
Loading…
Reference in New Issue
Block a user