mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-12 02:00:58 +01:00
Added extra comments and assertions to avoid user combining ImGuiCond flags. (#1694)
This commit is contained in:
parent
cd1e6e384f
commit
4649967112
@ -206,7 +206,8 @@ Breaking Changes:
|
||||
- Renamed `ImGuiTextBuffer::append()` helper to `appendf()`, and `appendv()` to `appendfv()` for consistency. If you copied the 'Log' demo in your code, it uses appendv() so that needs to be renamed.
|
||||
- ImDrawList: Removed 'bool anti_aliased = true' final parameter of `ImDrawList::AddPolyline()` and `ImDrawList::AddConvexPolyFilled()`. Prefer manipulating ImDrawList::Flags if you need to toggle them during the frame.
|
||||
- Style, ImDrawList: Renamed `style.AntiAliasedShapes` to `style.AntiAliasedFill` for consistency and as a way to explicitly break code that manipulate those flag at runtime. You can now manipulate ImDrawList::Flags.
|
||||
- Style, Begin: Removed `ImGuiWindowFlags_ShowBorders` window flag. Borders are now fully set up in the ImGuiStyle structure (see e.g. `style.FrameBorderSize`, `style.WindowBorderSize`). Use `ImGui::ShowStyleEditor()` to look them up.
|
||||
- Style, Begin: Removed `ImGuiWindowFlags_ShowBorders` window flag. Borders are now fully set up in the ImGuiStyle structure (see e.g. `style.FrameBorderSize`, `style.WindowBorderSize`, `style.PopupBorderSize`).
|
||||
Use `ImGui::ShowStyleEditor()` to look them up.
|
||||
Please note that the style system will keep evolving (hopefully stabilizing in Q1 2018), and so custom styles will probably subtly break over time.
|
||||
It is recommended that you use the `StyleColorsClassic()`, `StyleColorsDark()`, `StyleColorsLight()` functions. Also see `ShowStyleSelector()`.
|
||||
- Style: Removed `ImGuiCol_ComboBg` in favor of combo boxes using `ImGuiCol_PopupBg` for consistency. Combo are normal popups.
|
||||
@ -231,7 +232,8 @@ Other Changes:
|
||||
- Style: Added StyleColorsDark() style. (#707) [@dougbinks]
|
||||
- Style: Added StyleColorsLight() style. Best used with frame borders + thicker font than the default font. (#707)
|
||||
- Style: Added style.PopupRounding setting. (#1112)
|
||||
- Style: Added style.FrameBorderSize, style.WindowBorderSize. Removed ImGuiWindowFlags_ShowBorders window flag! Borders are now fully set up in the ImGuiStyle structure. Use ImGui::ShowStyleEditor() to look them up. (#707, fix #819, #1031)
|
||||
- Style: Added style.FrameBorderSize, style.WindowBorderSize, style.PopupBorderSize. Removed ImGuiWindowFlags_ShowBorders window flag!
|
||||
Borders are now fully set up in the ImGuiStyle structure. Use ImGui::ShowStyleEditor() to look them up. (#707, fix #819, #1031)
|
||||
- Style: Various small changes to the classic style (most noticeably, buttons are now using blue shades). (#707)
|
||||
- Style: Renamed ImGuiCol_ChildWindowBg to ImGuiCol_ChildBg.
|
||||
- Style: Renamed style.ChildWindowRounding to style.ChildRounding, ImGuiStyleVar_ChildWindowRounding to ImGuiStyleVar_ChildRounding.
|
||||
@ -261,6 +263,7 @@ Other Changes:
|
||||
- Window: Using the ImGuiWindowFlags_NoScrollWithMouse flag on a child window forwards the mouse wheel event to the parent window, unless either ImGuiWindowFlags_NoInputs or ImGuiWindowFlags_NoScrollbar are also set. (#1380, #1502)
|
||||
- Window: Active Modal window always set the WantCaptureKeyboard flag. (#744)
|
||||
- Window: Moving window doesn't use accumulating MouseDelta so straying out of imgui boundaries keeps moved imgui window at the same cursor-relative position.
|
||||
- Window: BeginChild() which an explicit name doesn't include the hash within the internal window name. (#1698)
|
||||
- IsWindowFocused(): Added ImGuiFocusedFlags_ChildWindows flag to include child windows in the focused test. (#1382).
|
||||
- IsWindowFocused(): Added ImGuiFocusedFlags_RootWindow flag to start focused test from the root (top-most) window. Obsolete IsRootWindowFocused(). (#1382)
|
||||
- IsWindowHovered(): Added ImGuiHoveredFlags_ChildWindows flag to include child windows in the hovered test. (#1382).
|
||||
|
@ -6846,6 +6846,8 @@ static void SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond)
|
||||
// Test condition (NB: bit 0 is always true) and clear flags for next time
|
||||
if (cond && (window->SetWindowPosAllowFlags & cond) == 0)
|
||||
return;
|
||||
|
||||
IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags.
|
||||
window->SetWindowPosAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing);
|
||||
window->SetWindowPosVal = ImVec2(FLT_MAX, FLT_MAX);
|
||||
|
||||
@ -6880,6 +6882,8 @@ static void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond con
|
||||
// Test condition (NB: bit 0 is always true) and clear flags for next time
|
||||
if (cond && (window->SetWindowSizeAllowFlags & cond) == 0)
|
||||
return;
|
||||
|
||||
IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags.
|
||||
window->SetWindowSizeAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing);
|
||||
|
||||
// Set
|
||||
@ -6971,6 +6975,7 @@ void ImGui::SetWindowFocus(const char* name)
|
||||
void ImGui::SetNextWindowPos(const ImVec2& pos, ImGuiCond cond, const ImVec2& pivot)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags.
|
||||
g.NextWindowData.PosVal = pos;
|
||||
g.NextWindowData.PosPivotVal = pivot;
|
||||
g.NextWindowData.PosCond = cond ? cond : ImGuiCond_Always;
|
||||
@ -6979,6 +6984,7 @@ void ImGui::SetNextWindowPos(const ImVec2& pos, ImGuiCond cond, const ImVec2& pi
|
||||
void ImGui::SetNextWindowSize(const ImVec2& size, ImGuiCond cond)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags.
|
||||
g.NextWindowData.SizeVal = size;
|
||||
g.NextWindowData.SizeCond = cond ? cond : ImGuiCond_Always;
|
||||
}
|
||||
@ -7002,6 +7008,7 @@ void ImGui::SetNextWindowContentSize(const ImVec2& size)
|
||||
void ImGui::SetNextWindowCollapsed(bool collapsed, ImGuiCond cond)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags.
|
||||
g.NextWindowData.CollapsedVal = collapsed;
|
||||
g.NextWindowData.CollapsedCond = cond ? cond : ImGuiCond_Always;
|
||||
}
|
||||
|
2
imgui.h
2
imgui.h
@ -937,7 +937,7 @@ enum ImGuiMouseCursor_
|
||||
};
|
||||
|
||||
// Condition for ImGui::SetWindow***(), SetNextWindow***(), SetNextTreeNode***() functions
|
||||
// All those functions treat 0 as a shortcut to ImGuiCond_Always. From the point of view of the user use this as an enum (don't combine multiple values into flags).
|
||||
// Important: Treat as a regular enum! Do NOT combine multiple values using binary operators! All the functions above treat 0 as a shortcut to ImGuiCond_Always.
|
||||
enum ImGuiCond_
|
||||
{
|
||||
ImGuiCond_Always = 1 << 0, // Set the variable
|
||||
|
Loading…
Reference in New Issue
Block a user