|
@@ -802,7 +802,7 @@ bool ImGui::CloseButton(ImGuiID id, const ImVec2& pos)
|
|
|
|
|
|
// Tweak 1: Shrink hit-testing area if button covers an abnormally large proportion of the visible region. That's in order to facilitate moving the window away. (#3825)
|
|
// Tweak 1: Shrink hit-testing area if button covers an abnormally large proportion of the visible region. That's in order to facilitate moving the window away. (#3825)
|
|
// This may better be applied as a general hit-rect reduction mechanism for all widgets to ensure the area to move window is always accessible?
|
|
// This may better be applied as a general hit-rect reduction mechanism for all widgets to ensure the area to move window is always accessible?
|
|
- const ImRect bb(pos, pos + ImVec2(g.FontSize, g.FontSize) + g.Style.FramePadding * 2.0f);
|
|
|
|
|
|
+ const ImRect bb(pos, pos + ImVec2(g.FontSize, g.FontSize));
|
|
ImRect bb_interact = bb;
|
|
ImRect bb_interact = bb;
|
|
const float area_to_visible_ratio = window->OuterRectClipped.GetArea() / bb.GetArea();
|
|
const float area_to_visible_ratio = window->OuterRectClipped.GetArea() / bb.GetArea();
|
|
if (area_to_visible_ratio < 1.5f)
|
|
if (area_to_visible_ratio < 1.5f)
|
|
@@ -838,7 +838,7 @@ bool ImGui::CollapseButton(ImGuiID id, const ImVec2& pos)
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiWindow* window = g.CurrentWindow;
|
|
ImGuiWindow* window = g.CurrentWindow;
|
|
|
|
|
|
- ImRect bb(pos, pos + ImVec2(g.FontSize, g.FontSize) + g.Style.FramePadding * 2.0f);
|
|
|
|
|
|
+ ImRect bb(pos, pos + ImVec2(g.FontSize, g.FontSize));
|
|
bool is_clipped = !ItemAdd(bb, id);
|
|
bool is_clipped = !ItemAdd(bb, id);
|
|
bool hovered, held;
|
|
bool hovered, held;
|
|
bool pressed = ButtonBehavior(bb, id, &hovered, &held, ImGuiButtonFlags_None);
|
|
bool pressed = ButtonBehavior(bb, id, &hovered, &held, ImGuiButtonFlags_None);
|
|
@@ -850,7 +850,7 @@ bool ImGui::CollapseButton(ImGuiID id, const ImVec2& pos)
|
|
ImU32 text_col = GetColorU32(ImGuiCol_Text);
|
|
ImU32 text_col = GetColorU32(ImGuiCol_Text);
|
|
if (hovered || held)
|
|
if (hovered || held)
|
|
window->DrawList->AddCircleFilled(bb.GetCenter() + ImVec2(0.0f, -0.5f), g.FontSize * 0.5f + 1.0f, bg_col);
|
|
window->DrawList->AddCircleFilled(bb.GetCenter() + ImVec2(0.0f, -0.5f), g.FontSize * 0.5f + 1.0f, bg_col);
|
|
- RenderArrow(window->DrawList, bb.Min + g.Style.FramePadding, text_col, window->Collapsed ? ImGuiDir_Right : ImGuiDir_Down, 1.0f);
|
|
|
|
|
|
+ RenderArrow(window->DrawList, bb.Min, text_col, window->Collapsed ? ImGuiDir_Right : ImGuiDir_Down, 1.0f);
|
|
|
|
|
|
// Switch to moving the window after mouse is moved beyond the initial drag threshold
|
|
// Switch to moving the window after mouse is moved beyond the initial drag threshold
|
|
if (IsItemActive() && IsMouseDragging(0))
|
|
if (IsItemActive() && IsMouseDragging(0))
|
|
@@ -6421,8 +6421,8 @@ bool ImGui::CollapsingHeader(const char* label, bool* p_visible, ImGuiTreeNodeFl
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiLastItemData last_item_backup = g.LastItemData;
|
|
ImGuiLastItemData last_item_backup = g.LastItemData;
|
|
float button_size = g.FontSize;
|
|
float button_size = g.FontSize;
|
|
- float button_x = ImMax(g.LastItemData.Rect.Min.x, g.LastItemData.Rect.Max.x - g.Style.FramePadding.x * 2.0f - button_size);
|
|
|
|
- float button_y = g.LastItemData.Rect.Min.y;
|
|
|
|
|
|
+ float button_x = ImMax(g.LastItemData.Rect.Min.x, g.LastItemData.Rect.Max.x - g.Style.FramePadding.x - button_size);
|
|
|
|
+ float button_y = g.LastItemData.Rect.Min.y + g.Style.FramePadding.y;
|
|
ImGuiID close_button_id = GetIDWithSeed("#CLOSE", NULL, id);
|
|
ImGuiID close_button_id = GetIDWithSeed("#CLOSE", NULL, id);
|
|
if (CloseButton(close_button_id, ImVec2(button_x, button_y)))
|
|
if (CloseButton(close_button_id, ImVec2(button_x, button_y)))
|
|
*p_visible = false;
|
|
*p_visible = false;
|
|
@@ -8596,7 +8596,7 @@ void ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb,
|
|
}
|
|
}
|
|
|
|
|
|
const float button_sz = g.FontSize;
|
|
const float button_sz = g.FontSize;
|
|
- const ImVec2 button_pos(ImMax(bb.Min.x, bb.Max.x - frame_padding.x * 2.0f - button_sz), bb.Min.y);
|
|
|
|
|
|
+ const ImVec2 button_pos(ImMax(bb.Min.x, bb.Max.x - frame_padding.x - button_sz), bb.Min.y + frame_padding.y);
|
|
|
|
|
|
// Close Button & Unsaved Marker
|
|
// Close Button & Unsaved Marker
|
|
// We are relying on a subtle and confusing distinction between 'hovered' and 'g.HoveredId' which happens because we are using ImGuiButtonFlags_AllowOverlapMode + SetItemAllowOverlap()
|
|
// We are relying on a subtle and confusing distinction between 'hovered' and 'g.HoveredId' which happens because we are using ImGuiButtonFlags_AllowOverlapMode + SetItemAllowOverlap()
|
|
@@ -8614,10 +8614,8 @@ void ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb,
|
|
if (close_button_visible)
|
|
if (close_button_visible)
|
|
{
|
|
{
|
|
ImGuiLastItemData last_item_backup = g.LastItemData;
|
|
ImGuiLastItemData last_item_backup = g.LastItemData;
|
|
- PushStyleVar(ImGuiStyleVar_FramePadding, frame_padding);
|
|
|
|
if (CloseButton(close_button_id, button_pos))
|
|
if (CloseButton(close_button_id, button_pos))
|
|
close_button_pressed = true;
|
|
close_button_pressed = true;
|
|
- PopStyleVar();
|
|
|
|
g.LastItemData = last_item_backup;
|
|
g.LastItemData = last_item_backup;
|
|
|
|
|
|
// Close with middle mouse button
|
|
// Close with middle mouse button
|