Skip to content

Commit d815895

Browse files
Merge branch 'ocornut:master' into features/modules
2 parents adb53b8 + 3ff8c46 commit d815895

File tree

8 files changed

+38
-27
lines changed

8 files changed

+38
-27
lines changed

docs/CHANGELOG.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Other Changes:
5151
- Textures:
5252
- Fixed a building issue when ImTextureID is defined as a struct.
5353
- Fixed displaying texture # in Metrics/Debugger window.
54+
- Menus: fixed MenuItem() label baseline when using inside a line with an offset.
5455
- Scrollbar: fixed a codepath leading to a divide-by-zero (which would not be
5556
noticeable by user but detected by sanitizers). (#9089) [@judicaelclair]
5657
- Backends:
@@ -61,6 +62,9 @@ Other Changes:
6162
selects `VkSwapchainCreateInfoKHR`'s `compositeAlpha` value based on
6263
`cap.supportedCompositeAlpha`, which seems to be required on some Android
6364
devices. (#8784) [@FelixStach]
65+
- Examples:
66+
- Win32+DirectX12: ignore seemingly incorrect D3D12_MESSAGE_ID_FENCE_ZERO_WAIT
67+
warning on startups on some setups. (#9084, #9093) [@RT2Code, @LeoGautheron]
6468

6569

6670
-----------------------------------------------------------------------

examples/example_apple_opengl2/main.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ -(BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theAppli
169169
-(NSWindow*)window
170170
{
171171
if (_window != nil)
172-
return (_window);
172+
return _window;
173173

174174
NSRect viewRect = NSMakeRect(100.0, 100.0, 100.0 + 1280.0, 100 + 800.0);
175175

@@ -179,7 +179,7 @@ -(NSWindow*)window
179179
[_window setOpaque:YES];
180180
[_window makeKeyAndOrderFront:NSApp];
181181

182-
return (_window);
182+
return _window;
183183
}
184184

185185
-(void)setupMenu

imgui.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2029,7 +2029,7 @@ bool ImTriangleContainsPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c,
20292029
bool b1 = ((p.x - b.x) * (a.y - b.y) - (p.y - b.y) * (a.x - b.x)) < 0.0f;
20302030
bool b2 = ((p.x - c.x) * (b.y - c.y) - (p.y - c.y) * (b.x - c.x)) < 0.0f;
20312031
bool b3 = ((p.x - a.x) * (c.y - a.y) - (p.y - a.y) * (c.x - a.x)) < 0.0f;
2032-
return ((b1 == b2) && (b2 == b3));
2032+
return (b1 == b2) && (b2 == b3);
20332033
}
20342034

20352035
void ImTriangleBarycentricCoords(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p, float& out_u, float& out_v, float& out_w)
@@ -3129,7 +3129,7 @@ IM_MSVC_RUNTIME_CHECKS_RESTORE
31293129
static bool GetSkipItemForListClipping()
31303130
{
31313131
ImGuiContext& g = *GImGui;
3132-
return (g.CurrentTable ? g.CurrentTable->HostSkipItems : g.CurrentWindow->SkipItems);
3132+
return g.CurrentTable ? g.CurrentTable->HostSkipItems : g.CurrentWindow->SkipItems;
31333133
}
31343134

31353135
static void ImGuiListClipper_SortAndFuseRanges(ImVector<ImGuiListClipperRange>& ranges, int offset = 0)
@@ -5290,7 +5290,7 @@ void ImGui::UpdateMouseMovingWindowEndFrame()
52905290

52915291
static bool IsWindowActiveAndVisible(ImGuiWindow* window)
52925292
{
5293-
return (window->Active) && (!window->Hidden);
5293+
return window->Active && !window->Hidden;
52945294
}
52955295

52965296
// The reason this is exposed in imgui_internal.h is: on touch-based system that don't have hovering, we want to dispatch inputs to the right target (imgui vs imgui+app)
@@ -5692,7 +5692,7 @@ static int IMGUI_CDECL ChildWindowComparer(const void* lhs, const void* rhs)
56925692
return d;
56935693
if (int d = (a->Flags & ImGuiWindowFlags_Tooltip) - (b->Flags & ImGuiWindowFlags_Tooltip))
56945694
return d;
5695-
return (a->BeginOrderWithinParent - b->BeginOrderWithinParent);
5695+
return a->BeginOrderWithinParent - b->BeginOrderWithinParent;
56965696
}
56975697

56985698
static void AddWindowToSortBuffer(ImVector<ImGuiWindow*>* out_sorted_windows, ImGuiWindow* window)
@@ -6168,7 +6168,7 @@ bool ImGui::IsItemDeactivated()
61686168
ImGuiContext& g = *GImGui;
61696169
if (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_HasDeactivated)
61706170
return (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_Deactivated) != 0;
6171-
return (g.DeactivatedItemData.ID == g.LastItemData.ID && g.LastItemData.ID != 0 && g.DeactivatedItemData.ElapseFrame >= g.FrameCount);
6171+
return g.DeactivatedItemData.ID == g.LastItemData.ID && g.LastItemData.ID != 0 && g.DeactivatedItemData.ElapseFrame >= g.FrameCount;
61726172
}
61736173

61746174
bool ImGui::IsItemDeactivatedAfterEdit()
@@ -9394,7 +9394,7 @@ int ImGui::CalcTypematicRepeatAmount(float t0, float t1, float repeat_delay, flo
93949394
if (t0 >= t1)
93959395
return 0;
93969396
if (repeat_rate <= 0.0f)
9397-
return (t0 < repeat_delay) && (t1 >= repeat_delay);
9397+
return t0 < repeat_delay && t1 >= repeat_delay;
93989398
const int count_t0 = (t0 < repeat_delay) ? -1 : (int)((t0 - repeat_delay) / repeat_rate);
93999399
const int count_t1 = (t1 < repeat_delay) ? -1 : (int)((t1 - repeat_delay) / repeat_rate);
94009400
const int count = count_t1 - count_t0;
@@ -10513,7 +10513,7 @@ bool ImGui::TestKeyOwner(ImGuiKey key, ImGuiID owner_id)
1051310513

1051410514
ImGuiKeyOwnerData* owner_data = GetKeyOwnerData(&g, key);
1051510515
if (owner_id == ImGuiKeyOwner_Any)
10516-
return (owner_data->LockThisFrame == false);
10516+
return owner_data->LockThisFrame == false;
1051710517

1051810518
// Note: SetKeyOwner() sets OwnerCurr. It is not strictly required for most mouse routing overlap (because of ActiveId/HoveredId
1051910519
// are acting as filter before this has a chance to filter), but sane as soon as user tries to look into things.
@@ -12693,7 +12693,7 @@ bool ImGui::IsWindowFocused(ImGuiFocusedFlags flags)
1269312693
if (flags & ImGuiFocusedFlags_ChildWindows)
1269412694
return IsWindowChildOf(ref_window, cur_window, popup_hierarchy);
1269512695
else
12696-
return (ref_window == cur_window);
12696+
return ref_window == cur_window;
1269712697
}
1269812698

1269912699
static int ImGui::FindWindowFocusIndex(ImGuiWindow* window)

imgui.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ namespace ImGui
897897
// - 5. Call EndTable()
898898
IMGUI_API bool BeginTable(const char* str_id, int columns, ImGuiTableFlags flags = 0, const ImVec2& outer_size = ImVec2(0.0f, 0.0f), float inner_width = 0.0f);
899899
IMGUI_API void EndTable(); // only call EndTable() if BeginTable() returns true!
900-
IMGUI_API void TableNextRow(ImGuiTableRowFlags row_flags = 0, float min_row_height = 0.0f); // append into the first cell of a new row.
900+
IMGUI_API void TableNextRow(ImGuiTableRowFlags row_flags = 0, float min_row_height = 0.0f); // append into the first cell of a new row. 'min_row_height' include the minimum top and bottom padding aka CellPadding.y * 2.0f.
901901
IMGUI_API bool TableNextColumn(); // append into the next column (or first column of next row if currently in last column). Return true when column is visible.
902902
IMGUI_API bool TableSetColumnIndex(int column_n); // append into the specified column. Return true when column is visible.
903903

imgui_demo.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2530,7 +2530,7 @@ struct ExampleDualListBox
25302530
{
25312531
const int* a = (const int*)lhs;
25322532
const int* b = (const int*)rhs;
2533-
return (*a - *b);
2533+
return *a - *b;
25342534
}
25352535
void SortItems(int n)
25362536
{
@@ -5545,7 +5545,7 @@ struct MyItem
55455545
// qsort() is instable so always return a way to differentiate items.
55465546
// Your own compare function may want to avoid fallback on implicit sort specs.
55475547
// e.g. a Name compare if it wasn't already part of the sort specs.
5548-
return (a->ID - b->ID);
5548+
return a->ID - b->ID;
55495549
}
55505550
};
55515551
const ImGuiTableSortSpecs* MyItem::s_current_sort_specs = NULL;
@@ -6509,7 +6509,7 @@ static void DemoWindowTables()
65096509
ImGui::TableNextColumn();
65106510
ImGui::Text("A0 Row 0");
65116511
{
6512-
float rows_height = TEXT_BASE_HEIGHT * 2;
6512+
float rows_height = (TEXT_BASE_HEIGHT * 2.0f) + (ImGui::GetStyle().CellPadding.y * 2.0f);
65136513
if (ImGui::BeginTable("table_nested2", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable))
65146514
{
65156515
ImGui::TableSetupColumn("B0");
@@ -6551,7 +6551,7 @@ static void DemoWindowTables()
65516551
{
65526552
for (int row = 0; row < 8; row++)
65536553
{
6554-
float min_row_height = (float)(int)(TEXT_BASE_HEIGHT * 0.30f * row);
6554+
float min_row_height = (float)(int)(TEXT_BASE_HEIGHT * 0.30f * row + ImGui::GetStyle().CellPadding.y * 2.0f);
65556555
ImGui::TableNextRow(ImGuiTableRowFlags_None, min_row_height);
65566556
ImGui::TableNextColumn();
65576557
ImGui::Text("min_row_height = %.2f", min_row_height);
@@ -6655,9 +6655,10 @@ static void DemoWindowTables()
66556655
ImGui::SameLine();
66566656
if (ImGui::BeginTable("table3", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg, ImVec2(TEXT_BASE_WIDTH * 30, 0.0f)))
66576657
{
6658+
const float rows_height = TEXT_BASE_HEIGHT * 1.5f + ImGui::GetStyle().CellPadding.y * 2.0f;
66586659
for (int row = 0; row < 3; row++)
66596660
{
6660-
ImGui::TableNextRow(0, TEXT_BASE_HEIGHT * 1.5f);
6661+
ImGui::TableNextRow(0, rows_height);
66616662
for (int column = 0; column < 3; column++)
66626663
{
66636664
ImGui::TableNextColumn();
@@ -10515,7 +10516,7 @@ struct ExampleAsset
1051510516
if (delta < 0)
1051610517
return (sort_spec->SortDirection == ImGuiSortDirection_Ascending) ? -1 : +1;
1051710518
}
10518-
return ((int)a->ID - (int)b->ID);
10519+
return (int)a->ID - (int)b->ID;
1051910520
}
1052010521
};
1052110522
const ImGuiTableSortSpecs* ExampleAsset::s_current_sort_specs = NULL;

imgui_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3651,7 +3651,7 @@ namespace ImGui
36513651
IMGUI_API void InputTextDeactivateHook(ImGuiID id);
36523652
IMGUI_API bool TempInputText(const ImRect& bb, ImGuiID id, const char* label, char* buf, int buf_size, ImGuiInputTextFlags flags);
36533653
IMGUI_API bool TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* p_data, const char* format, const void* p_clamp_min = NULL, const void* p_clamp_max = NULL);
3654-
inline bool TempInputIsActive(ImGuiID id) { ImGuiContext& g = *GImGui; return (g.ActiveId == id && g.TempInputId == id); }
3654+
inline bool TempInputIsActive(ImGuiID id) { ImGuiContext& g = *GImGui; return g.ActiveId == id && g.TempInputId == id; }
36553655
inline ImGuiInputTextState* GetInputTextState(ImGuiID id) { ImGuiContext& g = *GImGui; return (id != 0 && g.InputTextState.ID == id) ? &g.InputTextState : NULL; } // Get input text state if active
36563656
IMGUI_API void SetNextItemRefVal(ImGuiDataType data_type, void* p_data);
36573657
inline bool IsItemActiveAsInputText() { ImGuiContext& g = *GImGui; return g.ActiveId != 0 && g.ActiveId == g.LastItemData.ID && g.InputTextState.ID == g.LastItemData.ID; } // This may be useful to apply workaround that a based on distinguish whenever an item is active as a text input field.

imgui_tables.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2458,6 +2458,11 @@ void ImGui::TableUpdateColumnsWeightFromWidth(ImGuiTable* table)
24582458
// - TableDrawBorders() [Internal]
24592459
//-------------------------------------------------------------------------
24602460

2461+
2462+
// FIXME: This could be abstracted and merged with PushColumnsBackground(), by creating a generic struct
2463+
// with storage for backup cliprect + backup channel + storage for splitter pointer, new clip rect.
2464+
// This would slightly simplify caller code.
2465+
24612466
// Bg2 is used by Selectable (and possibly other widgets) to render to the background.
24622467
// Unlike our Bg0/1 channel which we uses for RowBg/CellBg/Borders and where we guarantee all shapes to be CPU-clipped, the Bg2 channel being widgets-facing will rely on regular ClipRect.
24632468
void ImGui::TablePushBackgroundChannel()

imgui_widgets.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,7 +1834,7 @@ static int IMGUI_CDECL ShrinkWidthItemComparer(const void* lhs, const void* rhs)
18341834
const ImGuiShrinkWidthItem* b = (const ImGuiShrinkWidthItem*)rhs;
18351835
if (int d = (int)(b->Width - a->Width))
18361836
return d;
1837-
return (b->Index - a->Index);
1837+
return b->Index - a->Index;
18381838
}
18391839

18401840
// Shrink excess width from a set of item, by removing width from the larger items first.
@@ -9227,13 +9227,13 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled)
92279227
float checkmark_w = IM_TRUNC(g.FontSize * 1.20f);
92289228
float min_w = window->DC.MenuColumns.DeclColumns(icon_w, label_size.x, 0.0f, checkmark_w); // Feedback to next frame
92299229
float extra_w = ImMax(0.0f, GetContentRegionAvail().x - min_w);
9230-
ImVec2 text_pos(window->DC.CursorPos.x + offsets->OffsetLabel, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset);
9230+
ImVec2 text_pos(window->DC.CursorPos.x, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset);
92319231
pressed = Selectable("", menu_is_open, selectable_flags | ImGuiSelectableFlags_SpanAvailWidth, ImVec2(min_w, label_size.y));
92329232
LogSetNextTextDecoration("", ">");
9233-
RenderText(text_pos, label);
9233+
RenderText(ImVec2(text_pos.x + offsets->OffsetLabel, text_pos.y), label);
92349234
if (icon_w > 0.0f)
9235-
RenderText(pos + ImVec2(offsets->OffsetIcon, 0.0f), icon);
9236-
RenderArrow(window->DrawList, pos + ImVec2(offsets->OffsetMark + extra_w + g.FontSize * 0.30f, 0.0f), GetColorU32(ImGuiCol_Text), ImGuiDir_Right);
9235+
RenderText(ImVec2(text_pos.x + offsets->OffsetIcon, text_pos.y), icon);
9236+
RenderArrow(window->DrawList, ImVec2(text_pos.x + offsets->OffsetMark + extra_w + g.FontSize * 0.30f, text_pos.y), GetColorU32(ImGuiCol_Text), ImGuiDir_Right);
92379237
}
92389238
if (!enabled)
92399239
EndDisabled();
@@ -9434,21 +9434,22 @@ bool ImGui::MenuItemEx(const char* label, const char* icon, const char* shortcut
94349434
float checkmark_w = IM_TRUNC(g.FontSize * 1.20f);
94359435
float min_w = window->DC.MenuColumns.DeclColumns(icon_w, label_size.x, shortcut_w, checkmark_w); // Feedback for next frame
94369436
float stretch_w = ImMax(0.0f, GetContentRegionAvail().x - min_w);
9437+
ImVec2 text_pos(pos.x, pos.y + window->DC.CurrLineTextBaseOffset);
94379438
pressed = Selectable("", false, selectable_flags | ImGuiSelectableFlags_SpanAvailWidth, ImVec2(min_w, label_size.y));
94389439
if (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_Visible)
94399440
{
9440-
RenderText(pos + ImVec2(offsets->OffsetLabel, 0.0f), label);
9441+
RenderText(text_pos + ImVec2(offsets->OffsetLabel, 0.0f), label);
94419442
if (icon_w > 0.0f)
9442-
RenderText(pos + ImVec2(offsets->OffsetIcon, 0.0f), icon);
9443+
RenderText(text_pos + ImVec2(offsets->OffsetIcon, 0.0f), icon);
94439444
if (shortcut_w > 0.0f)
94449445
{
94459446
PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]);
94469447
LogSetNextTextDecoration("(", ")");
9447-
RenderText(pos + ImVec2(offsets->OffsetShortcut + stretch_w, 0.0f), shortcut, NULL, false);
9448+
RenderText(text_pos + ImVec2(offsets->OffsetShortcut + stretch_w, 0.0f), shortcut, NULL, false);
94489449
PopStyleColor();
94499450
}
94509451
if (selected)
9451-
RenderCheckMark(window->DrawList, pos + ImVec2(offsets->OffsetMark + stretch_w + g.FontSize * 0.40f, g.FontSize * 0.134f * 0.5f), GetColorU32(ImGuiCol_Text), g.FontSize * 0.866f);
9452+
RenderCheckMark(window->DrawList, text_pos + ImVec2(offsets->OffsetMark + stretch_w + g.FontSize * 0.40f, g.FontSize * 0.134f * 0.5f), GetColorU32(ImGuiCol_Text), g.FontSize * 0.866f);
94529453
}
94539454
}
94549455
IMGUI_TEST_ENGINE_ITEM_INFO(g.LastItemData.ID, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Checkable | (selected ? ImGuiItemStatusFlags_Checked : 0));

0 commit comments

Comments
 (0)