mirror of
https://github.com/ocornut/imgui.git
synced 2024-12-12 20:19:02 +08:00
Merge branch 'master' into docking
# Conflicts: # imgui.cpp
This commit is contained in:
commit
f87e891f18
@ -132,6 +132,8 @@ Breaking changes:
|
||||
semantic, but the additional indirection and copy added complexity and got in the way of other
|
||||
incoming work. User's code (other than backends) should not be affected, unless you have custom
|
||||
widgets intercepting navigation events via the named enums (in which case you can upgrade your code).
|
||||
- Removed runtime patching of invalid "%f"/"%.0f" types of format strings for DragInt()/SliderInt().
|
||||
This was obsoleted in 1.61 (May 2018). See 1.61 changelog for details.
|
||||
- Changed signature of ImageButton() function: (#5533, #4471, #2464, #1390)
|
||||
- Added 'const char* str_id' parameter + removed 'int frame_padding = -1' parameter.
|
||||
- Old signature: bool ImageButton(ImTextureID tex_id, ImVec2 size, ImVec2 uv0 = ImVec2(0,0), ImVec2 uv1 = ImVec2(1,1), int frame_padding = -1, ImVec4 bg_col = ImVec4(0,0,0,0), ImVec4 tint_col = ImVec4(1,1,1,1));
|
||||
@ -189,6 +191,8 @@ Other Changes:
|
||||
io.HoverDelayNormal (default to 0.30f) and io.HoverDelayFast (default to 0.10f). (#1485)
|
||||
- IsItemHovered: Added ImGuiHoveredFlags_NoSharedDelay to disable sharing delays between itemm,
|
||||
so moving from one item to a nearby one will requires delay to elapse again. (#1485)
|
||||
- Tables: activating an ID (e.g. clicking button inside) column doesn't prevent columns
|
||||
output flags from having ImGuiTableColumnFlags_IsHovered set. (#2957)
|
||||
- Tables,Columns: fixed a layout issue where SameLine() prior to a row change would set the
|
||||
next row in such state where subsequent SameLine() would move back to previous row.
|
||||
- Tabs: Fixed a crash when closing multiple windows (possible with docking only) with an
|
||||
@ -207,6 +211,10 @@ Other Changes:
|
||||
towards a sub-menu. (#2517, #5614). [@rokups]
|
||||
- Menus: Fixed gaps in closing logic which would make child-menu erroneously close when crossing
|
||||
the gap between a menu item inside a window and a child-menu in a secondary viewport. (#5614)
|
||||
- Menus: Fixed using IsItemHovered()/IsItemClicked() on BeginMenu(). (#5775)
|
||||
- Menus, Popups: Experimental fix for issue where clicking on an open BeginMenu() item called from
|
||||
a window which is neither a popup neither a menu used to incorrectly close and reopen the menu.
|
||||
(the fix may have side-effect so labelld as experimental as we may need to revert) (#5775)
|
||||
- Menus, Nav: Fixed keyboard/gamepad navigation occasionally erroneously landing on menu-item
|
||||
in parent window when the parent is not a popup. (#5730)
|
||||
- Menus, Nav: Fixed not being able to close a menu with Left arrow when parent is not a popup. (#5730)
|
||||
|
@ -277,8 +277,8 @@ io.Fonts->GetTexDataAsRGBA32(&tex_pixels, &tex_width, &tex_height);
|
||||
|
||||
for (int rect_n = 0; rect_n < IM_ARRAYSIZE(rect_ids); rect_n++)
|
||||
{
|
||||
int rect_id = rects_ids[rect_n];
|
||||
if (const ImFontAtlas::CustomRect* rect = io.Fonts->GetCustomRectByIndex(rect_id))
|
||||
int rect_id = rect_ids[rect_n];
|
||||
if (const ImFontAtlasCustomRect* rect = io.Fonts->GetCustomRectByIndex(rect_id))
|
||||
{
|
||||
// Fill the custom rectangle with red pixels (in reality you would draw/copy your bitmap data here!)
|
||||
for (int y = 0; y < rect->Height; y++)
|
||||
|
@ -392,6 +392,7 @@ CODE
|
||||
- likewise io.MousePos and GetMousePos() will use OS coordinates.
|
||||
If you query mouse positions to interact with non-imgui coordinates you will need to offset them, e.g. subtract GetWindowViewport()->Pos.
|
||||
|
||||
- 2022/10/12 (1.89) - removed runtime patching of invalid "%f"/"%0.f" format strings for DragInt()/SliderInt(). This was obsoleted in 1.61 (May 2018). See 1.61 changelog for details.
|
||||
- 2022/09/26 (1.89) - renamed and merged keyboard modifiers key enums and flags into a same set. Kept inline redirection enums (will obsolete).
|
||||
- ImGuiKey_ModCtrl and ImGuiModFlags_Ctrl -> ImGuiMod_Ctrl
|
||||
- ImGuiKey_ModShift and ImGuiModFlags_Shift -> ImGuiMod_Shift
|
||||
@ -3718,7 +3719,7 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
|
||||
|
||||
// Test if interactions on this window are blocked by an active popup or modal.
|
||||
// The ImGuiHoveredFlags_AllowWhenBlockedByPopup flag will be tested here.
|
||||
if (!IsWindowContentHoverable(window, flags))
|
||||
if (!IsWindowContentHoverable(window, flags) && !(g.LastItemData.InFlags & ImGuiItemFlags_NoWindowHoverableCheck))
|
||||
return false;
|
||||
|
||||
// Test if the item is disabled
|
||||
@ -7563,10 +7564,10 @@ void ImGui::FocusWindow(ImGuiWindow* window)
|
||||
g.NavLayer = ImGuiNavLayer_Main;
|
||||
g.NavFocusScopeId = 0;
|
||||
g.NavIdIsAlive = false;
|
||||
}
|
||||
|
||||
// Close popups if any
|
||||
ClosePopupsOverWindow(window, false);
|
||||
// Close popups if any
|
||||
ClosePopupsOverWindow(window, false);
|
||||
}
|
||||
|
||||
// Move the root window to the top of the pile
|
||||
IM_ASSERT(window == NULL || window->RootWindowDockTree != NULL);
|
||||
|
13
imgui.h
13
imgui.h
@ -23,7 +23,7 @@
|
||||
// Library Version
|
||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM > 12345')
|
||||
#define IMGUI_VERSION "1.89 WIP"
|
||||
#define IMGUI_VERSION_NUM 18829
|
||||
#define IMGUI_VERSION_NUM 18832
|
||||
#define IMGUI_HAS_TABLE
|
||||
#define IMGUI_HAS_VIEWPORT // Viewport WIP branch
|
||||
#define IMGUI_HAS_DOCK // Docking WIP branch
|
||||
@ -1231,12 +1231,6 @@ enum ImGuiTableFlags_
|
||||
|
||||
// [Internal] Combinations and masks
|
||||
ImGuiTableFlags_SizingMask_ = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_SizingFixedSame | ImGuiTableFlags_SizingStretchProp | ImGuiTableFlags_SizingStretchSame,
|
||||
|
||||
// Obsolete names (will be removed soon)
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
//, ImGuiTableFlags_ColumnsWidthFixed = ImGuiTableFlags_SizingFixedFit, ImGuiTableFlags_ColumnsWidthStretch = ImGuiTableFlags_SizingStretchSame // WIP Tables 2020/12
|
||||
//, ImGuiTableFlags_SizingPolicyFixed = ImGuiTableFlags_SizingFixedFit, ImGuiTableFlags_SizingPolicyStretch = ImGuiTableFlags_SizingStretchSame // WIP Tables 2021/01
|
||||
#endif
|
||||
};
|
||||
|
||||
// Flags for ImGui::TableSetupColumn()
|
||||
@ -1274,11 +1268,6 @@ enum ImGuiTableColumnFlags_
|
||||
ImGuiTableColumnFlags_IndentMask_ = ImGuiTableColumnFlags_IndentEnable | ImGuiTableColumnFlags_IndentDisable,
|
||||
ImGuiTableColumnFlags_StatusMask_ = ImGuiTableColumnFlags_IsEnabled | ImGuiTableColumnFlags_IsVisible | ImGuiTableColumnFlags_IsSorted | ImGuiTableColumnFlags_IsHovered,
|
||||
ImGuiTableColumnFlags_NoDirectResize_ = 1 << 30, // [Internal] Disable user resizing this column directly (it may however we resized indirectly from its left edge)
|
||||
|
||||
// Obsolete names (will be removed soon)
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
//ImGuiTableColumnFlags_WidthAuto = ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_NoResize, // Column will not stretch and keep resizing based on submitted contents.
|
||||
#endif
|
||||
};
|
||||
|
||||
// Flags for ImGui::TableNextRow()
|
||||
|
@ -1320,6 +1320,7 @@ IM_STATIC_ASSERT(ImDrawFlags_RoundCornersTopLeft == (1 << 4));
|
||||
static inline ImDrawFlags FixRectCornerFlags(ImDrawFlags flags)
|
||||
{
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
// Obsoleted in 1.82 (from February 2021)
|
||||
// Legacy Support for hard coded ~0 (used to be a suggested equivalent to ImDrawCornerFlags_All)
|
||||
// ~0 --> ImDrawFlags_RoundCornersAll or 0
|
||||
if (flags == ~0)
|
||||
|
@ -936,11 +936,19 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
||||
width_remaining_for_stretched_columns -= 1.0f;
|
||||
}
|
||||
|
||||
// Determine if table is hovered which will be used to flag columns as hovered.
|
||||
// - In principle we'd like to use the equivalent of IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem),
|
||||
// but because our item is partially submitted at this point we use ItemHoverable() and a workaround (temporarily
|
||||
// clear ActiveId, which is equivalent to the change provided by _AllowWhenBLockedByActiveItem).
|
||||
// - This allows columns to be marked as hovered when e.g. clicking a button inside the column, or using drag and drop.
|
||||
ImGuiTableInstanceData* table_instance = TableGetInstanceData(table, table->InstanceCurrent);
|
||||
table->HoveredColumnBody = -1;
|
||||
table->HoveredColumnBorder = -1;
|
||||
const ImRect mouse_hit_rect(table->OuterRect.Min.x, table->OuterRect.Min.y, table->OuterRect.Max.x, ImMax(table->OuterRect.Max.y, table->OuterRect.Min.y + table_instance->LastOuterHeight));
|
||||
const ImGuiID backup_active_id = g.ActiveId;
|
||||
g.ActiveId = 0;
|
||||
const bool is_hovering_table = ItemHoverable(mouse_hit_rect, 0);
|
||||
g.ActiveId = backup_active_id;
|
||||
|
||||
// [Part 6] Setup final position, offset, skip/clip states and clipping rectangles, detect hovered column
|
||||
// Process columns in their visible orders as we are comparing the visible order and adjusting host_clip_rect while looping.
|
||||
|
@ -1903,7 +1903,6 @@ bool ImGui::Combo(const char* label, int* current_item, const char* items_separa
|
||||
//-------------------------------------------------------------------------
|
||||
// [SECTION] Data Type and Data Formatting Helpers [Internal]
|
||||
//-------------------------------------------------------------------------
|
||||
// - PatchFormatStringFloatToInt()
|
||||
// - DataTypeGetInfo()
|
||||
// - DataTypeFormatString()
|
||||
// - DataTypeApplyOp()
|
||||
@ -1934,30 +1933,6 @@ static const ImGuiDataTypeInfo GDataTypeInfo[] =
|
||||
};
|
||||
IM_STATIC_ASSERT(IM_ARRAYSIZE(GDataTypeInfo) == ImGuiDataType_COUNT);
|
||||
|
||||
// FIXME-LEGACY: Prior to 1.61 our DragInt() function internally used floats and because of this the compile-time default value for format was "%.0f".
|
||||
// Even though we changed the compile-time default, we expect users to have carried %f around, which would break the display of DragInt() calls.
|
||||
// To honor backward compatibility we are rewriting the format string, unless IMGUI_DISABLE_OBSOLETE_FUNCTIONS is enabled. What could possibly go wrong?!
|
||||
static const char* PatchFormatStringFloatToInt(const char* fmt)
|
||||
{
|
||||
if (fmt[0] == '%' && fmt[1] == '.' && fmt[2] == '0' && fmt[3] == 'f' && fmt[4] == 0) // Fast legacy path for "%.0f" which is expected to be the most common case.
|
||||
return "%d";
|
||||
const char* fmt_start = ImParseFormatFindStart(fmt); // Find % (if any, and ignore %%)
|
||||
const char* fmt_end = ImParseFormatFindEnd(fmt_start); // Find end of format specifier, which itself is an exercise of confidence/recklessness (because snprintf is dependent on libc or user).
|
||||
if (fmt_end > fmt_start && fmt_end[-1] == 'f')
|
||||
{
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
if (fmt_start == fmt && fmt_end[0] == 0)
|
||||
return "%d";
|
||||
const char* tmp_format;
|
||||
ImFormatStringToTempBuffer(&tmp_format, NULL, "%.*s%%d%s", (int)(fmt_start - fmt), fmt, fmt_end); // Honor leading and trailing decorations, but lose alignment/precision.
|
||||
return tmp_format;
|
||||
#else
|
||||
IM_ASSERT(0 && "DragInt(): Invalid format string!"); // Old versions used a default parameter of "%.0f", please replace with e.g. "%d"
|
||||
#endif
|
||||
}
|
||||
return fmt;
|
||||
}
|
||||
|
||||
const ImGuiDataTypeInfo* ImGui::DataTypeGetInfo(ImGuiDataType data_type)
|
||||
{
|
||||
IM_ASSERT(data_type >= 0 && data_type < ImGuiDataType_COUNT);
|
||||
@ -2371,8 +2346,6 @@ bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* p_data,
|
||||
// Default format string when passing NULL
|
||||
if (format == NULL)
|
||||
format = DataTypeGetInfo(data_type)->PrintFmt;
|
||||
else if (data_type == ImGuiDataType_S32 && strcmp(format, "%d") != 0) // (FIXME-LEGACY: Patch old "%.0f" format string to use "%d", read function more details.)
|
||||
format = PatchFormatStringFloatToInt(format);
|
||||
|
||||
const bool hovered = ItemHoverable(frame_bb, id);
|
||||
bool temp_input_is_active = temp_input_allowed && TempInputIsActive(id);
|
||||
@ -2964,8 +2937,6 @@ bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* p_dat
|
||||
// Default format string when passing NULL
|
||||
if (format == NULL)
|
||||
format = DataTypeGetInfo(data_type)->PrintFmt;
|
||||
else if (data_type == ImGuiDataType_S32 && strcmp(format, "%d") != 0) // (FIXME-LEGACY: Patch old "%.0f" format string to use "%d", read function more details.)
|
||||
format = PatchFormatStringFloatToInt(format);
|
||||
|
||||
const bool hovered = ItemHoverable(frame_bb, id);
|
||||
bool temp_input_is_active = temp_input_allowed && TempInputIsActive(id);
|
||||
@ -3131,8 +3102,6 @@ bool ImGui::VSliderScalar(const char* label, const ImVec2& size, ImGuiDataType d
|
||||
// Default format string when passing NULL
|
||||
if (format == NULL)
|
||||
format = DataTypeGetInfo(data_type)->PrintFmt;
|
||||
else if (data_type == ImGuiDataType_S32 && strcmp(format, "%d") != 0) // (FIXME-LEGACY: Patch old "%.0f" format string to use "%d", read function more details.)
|
||||
format = PatchFormatStringFloatToInt(format);
|
||||
|
||||
const bool hovered = ItemHoverable(frame_bb, id);
|
||||
if ((hovered && g.IO.MouseClicked[0]) || g.NavActivateId == id || g.NavActivateInputId == id)
|
||||
@ -7169,11 +7138,19 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled)
|
||||
|
||||
if (menu_is_open)
|
||||
{
|
||||
// FIXME: This technically breaks functions relying on LastItemData, somehow nobody complained yet. Should backup/restore LastItemData.
|
||||
ImGuiLastItemData last_item_in_parent = g.LastItemData;
|
||||
SetNextWindowPos(popup_pos, ImGuiCond_Always); // Note: misleading: the value will serve as reference for FindBestWindowPosForPopup(), not actual pos.
|
||||
PushStyleVar(ImGuiStyleVar_ChildRounding, style.PopupRounding); // First level will use _PopupRounding, subsequent will use _ChildRounding
|
||||
menu_is_open = BeginPopupEx(id, flags); // menu_is_open can be 'false' when the popup is completely clipped (e.g. zero size display)
|
||||
PopStyleVar();
|
||||
if (menu_is_open)
|
||||
{
|
||||
// Restore LastItemData so IsItemXXXX functions can work after BeginMenu()/EndMenu()
|
||||
// (This fixes using IsItemClicked() and IsItemHovered(), but IsItemHovered() also relies on its support for ImGuiItemFlags_NoWindowHoverableCheck)
|
||||
g.LastItemData = last_item_in_parent;
|
||||
if (g.HoveredWindow == window)
|
||||
g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_HoveredWindow;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user