mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-07 13:35:49 +02:00
Merge branch 'master' into navigation
# Conflicts: # imgui.cpp # imgui_demo.cpp
This commit is contained in:
173
imgui.cpp
173
imgui.cpp
@ -30,11 +30,12 @@
|
||||
- I integrated ImGui in my engine and the text or lines are blurry..
|
||||
- I integrated ImGui in my engine and some elements are clipping or disappearing when I move windows around..
|
||||
- How can I have multiple widgets with the same label? Can I have widget without a label? (Yes). A primer on the purpose of labels/IDs.
|
||||
- How can I tell when ImGui wants my mouse/keyboard inputs and when I can pass them to my application?
|
||||
- How can I tell when ImGui wants my mouse/keyboard inputs VS when I can pass them to my application?
|
||||
- How can I load a different font than the default?
|
||||
- How can I easily use icons in my application?
|
||||
- How can I load multiple fonts?
|
||||
- How can I display and input non-latin characters such as Chinese, Japanese, Korean, Cyrillic?
|
||||
- How can I preserve my ImGui context across reloading a DLL? (loss of the global/static variables)
|
||||
- How can I use the drawing facilities without an ImGui window? (using ImDrawList API)
|
||||
- ISSUES & TODO-LIST
|
||||
- CODE
|
||||
@ -194,7 +195,9 @@
|
||||
Here is a change-log of API breaking changes, if you are using one of the functions listed, expect to have to fix some code.
|
||||
Also read releases logs https://github.com/ocornut/imgui/releases for more details.
|
||||
|
||||
- 2017/07/30 (1.51) - removed ColorEditMode() and ImGuiColorEditMode in favor of ImGuiColorEditFlags and parameters to the various Color*() functions. The SetColorEditOptions() allows to initialize default but the user can still change them with right-click context menu.
|
||||
- 2017/08/11 (1.51) - renamed ImGuiSetCond_*** types and flags to ImGuiCond_***. Kept redirection enums (will obsolete).
|
||||
- 2017/08/09 (1.51) - removed ValueColor() helpers, they are equivalent to calling Text(label) + SameLine() + ColorButton().
|
||||
- 2017/08/08 (1.51) - removed ColorEditMode() and ImGuiColorEditMode in favor of ImGuiColorEditFlags and parameters to the various Color*() functions. The SetColorEditOptions() allows to initialize default but the user can still change them with right-click context menu.
|
||||
- changed prototype of 'ColorEdit4(const char* label, float col[4], bool show_alpha = true)' to 'ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flags = 0)', where passing flags = 0x01 is a safe no-op (hello dodgy backward compatibility!). - check and run the demo window, under "Color/Picker Widgets", to understand the various new options.
|
||||
- changed prototype of rarely used 'ColorButton(ImVec4 col, bool small_height = false, bool outline_border = true)' to 'ColorButton(const char* desc_id, ImVec4 col, ImGuiColorEditFlags flags = 0, ImVec2 size = ImVec2(0,0))'
|
||||
- 2017/07/20 (1.51) - removed IsPosHoveringAnyWindow(ImVec2), which was partly broken and misleading. ASSERT + redirect user to io.WantCaptureMouse
|
||||
@ -444,7 +447,7 @@
|
||||
e.g. when displaying a single object that may change over time (1-1 relationship), using a static string as ID will preserve your node open/closed state when the targeted object change.
|
||||
e.g. when displaying a list of objects, using indices or pointers as ID will preserve the node open/closed state differently. experiment and see what makes more sense!
|
||||
|
||||
Q: How can I tell when ImGui wants my mouse/keyboard inputs and when I can pass them to my application?
|
||||
Q: How can I tell when ImGui wants my mouse/keyboard inputs VS when I can pass them to my application?
|
||||
A: You can read the 'io.WantCaptureMouse'/'io.WantCaptureKeyboard'/'ioWantTextInput' flags from the ImGuiIO structure.
|
||||
- When 'io.WantCaptureMouse' or 'io.WantCaptureKeyboard' flags are set you may want to discard/hide the inputs from the rest of your application.
|
||||
- When 'io.WantTextInput' is set to may want to notify your OS to popup an on-screen keyboard, if available (e.g. on a mobile phone, or console without a keyboard).
|
||||
@ -495,19 +498,33 @@
|
||||
|
||||
Q: How can I display and input non-Latin characters such as Chinese, Japanese, Korean, Cyrillic?
|
||||
A: When loading a font, pass custom Unicode ranges to specify the glyphs to load.
|
||||
All your strings needs to use UTF-8 encoding. Specifying literal in your source code using a local code page (such as CP-923 for Japanese or CP-1251 for Cyrillic) will not work.
|
||||
In C++11 you can encode a string literal in UTF-8 by using the u8"hello" syntax. Otherwise you can convert yourself to UTF-8 or load text data from file already saved as UTF-8.
|
||||
You can also try to remap your local codepage characters to their Unicode codepoint using font->AddRemapChar(), but international users may have problems reading/editing your source code.
|
||||
|
||||
io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels, NULL, io.Fonts->GetGlyphRangesJapanese()); // Load Japanese characters
|
||||
io.Fonts->GetTexDataAsRGBA32() or GetTexDataAsAlpha8()
|
||||
io.ImeWindowHandle = MY_HWND; // To input using Microsoft IME, give ImGui the hwnd of your application
|
||||
// Add default Japanese ranges
|
||||
io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels, NULL, io.Fonts->GetGlyphRangesJapanese());
|
||||
|
||||
// Or create your own custom ranges (e.g. for a game you can feed your entire game script and only build the characters the game need)
|
||||
ImVector<ImWchar> ranges;
|
||||
ImFontAtlas::GlyphRangesBuilder builder;
|
||||
builder.AddText("Hello world"); // Add a string (here "Hello world" contains 7 unique characters)
|
||||
builder.AddChar(0x7262); // Add a specific character
|
||||
builder.AddRanges(io.Fonts->GetGlyphRangesJapanese()); // Add one of the default ranges
|
||||
builder.BuildRanges(&ranges); // Build the final result (ordered ranges with all the unique characters submitted)
|
||||
io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels, NULL, ranges.Data);
|
||||
|
||||
As for text input, depends on you passing the right character code to io.AddInputCharacter(). The example applications do that.
|
||||
All your strings needs to use UTF-8 encoding. In C++11 you can encode a string literal in UTF-8 by using the u8"hello" syntax.
|
||||
Specifying literal in your source code using a local code page (such as CP-923 for Japanese or CP-1251 for Cyrillic) will NOT work!
|
||||
Otherwise you can convert yourself to UTF-8 or load text data from file already saved as UTF-8.
|
||||
|
||||
Text input: it is up to your application to pass the right character code to io.AddInputCharacter(). The applications in examples/ are doing that.
|
||||
For languages using IME, on Windows you can copy the Hwnd of your application to io.ImeWindowHandle. The default implementation of io.ImeSetInputScreenPosFn() on Windows will set your IME position correctly.
|
||||
|
||||
Q: How can I preserve my ImGui context across reloading a DLL? (loss of the global/static variables)
|
||||
A: Create your own context 'ctx = CreateContext()' + 'SetCurrentContext(ctx)' and your own font atlas 'ctx->GetIO().Fonts = new ImFontAtlas()' so you don't rely on the default globals.
|
||||
|
||||
Q: How can I use the drawing facilities without an ImGui window? (using ImDrawList API)
|
||||
A: The easiest way is to create a dummy window. Call Begin() with NoTitleBar|NoResize|NoMove|NoScrollbar|NoSavedSettings|NoInputs flag, zero background alpha,
|
||||
then retrieve the ImDrawList* via GetWindowDrawList() and draw to it in any way you like.
|
||||
You can also perfectly create a standalone ImDrawList instance _but_ you need ImGui to be initialized because ImDrawList pulls from ImGui data to retrieve the coordinates of the white pixel.
|
||||
|
||||
- tip: the construct 'IMGUI_ONCE_UPON_A_FRAME { ... }' will run the block of code only once a frame. You can use it to quickly add custom UI in the middle of a deep nested inner loop in your code.
|
||||
- tip: you can create widgets without a Begin()/End() block, they will go in an implicit window called "Debug"
|
||||
@ -725,9 +742,9 @@ static void SetCurrentFont(ImFont* font);
|
||||
static void SetCurrentWindow(ImGuiWindow* window);
|
||||
static void SetWindowScrollX(ImGuiWindow* window, float new_scroll_x);
|
||||
static void SetWindowScrollY(ImGuiWindow* window, float new_scroll_y);
|
||||
static void SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiSetCond cond);
|
||||
static void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiSetCond cond);
|
||||
static void SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiSetCond cond);
|
||||
static void SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond);
|
||||
static void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond cond);
|
||||
static void SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond cond);
|
||||
static ImGuiWindow* FindHoveredWindow(ImVec2 pos, bool excluding_childs);
|
||||
static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFlags flags);
|
||||
static inline bool IsWindowContentHoverable(ImGuiWindow* window);
|
||||
@ -778,12 +795,13 @@ static void ImeSetInputScreenPosFn_DefaultImpl(int x, int y);
|
||||
// Context
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Default font atlas storage .
|
||||
// Default font atlas storage.
|
||||
// New contexts always point by default to this font atlas. It can be changed by reassigning the GetIO().Fonts variable.
|
||||
static ImFontAtlas GImDefaultFontAtlas;
|
||||
|
||||
// Default context storage + current context pointer.
|
||||
// Implicitely used by all ImGui functions. Always assumed to be != NULL. Change to a different context by calling ImGui::SetCurrentContext()
|
||||
// If you are hot-reloading this code in a DLL you will lose the static/global variables. Create your own context+font atlas instead of relying on those default (see FAQ entry "How can I preserve my ImGui context across reloading a DLL?").
|
||||
// ImGui is currently not thread-safe because of this variable. If you want thread-safety to allow N threads to access N different contexts, you might work around it by:
|
||||
// - Having multiple instances of the ImGui code compiled inside different namespace (easiest/safest, if you have a finite number of contexts)
|
||||
// - or: Changing this variable to be TLS. You may #define GImGui in imconfig.h for further custom hackery. Future development aim to make this context pointer explicit to all calls. Also read https://github.com/ocornut/imgui/issues/586
|
||||
@ -1910,7 +1928,7 @@ ImGuiWindow::ImGuiWindow(const char* name)
|
||||
AutoFitChildAxises = 0x00;
|
||||
AutoPosLastDirection = -1;
|
||||
HiddenFrames = 0;
|
||||
SetWindowPosAllowFlags = SetWindowSizeAllowFlags = SetWindowCollapsedAllowFlags = ImGuiSetCond_Always | ImGuiSetCond_Once | ImGuiSetCond_FirstUseEver | ImGuiSetCond_Appearing;
|
||||
SetWindowPosAllowFlags = SetWindowSizeAllowFlags = SetWindowCollapsedAllowFlags = ImGuiCond_Always | ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing;
|
||||
SetWindowPosCenterWanted = false;
|
||||
|
||||
LastFrameActive = -1;
|
||||
@ -3112,7 +3130,7 @@ void ImGui::NewFrame()
|
||||
CloseInactivePopups();
|
||||
|
||||
// Create implicit window - we will only render it if the user has added something to it.
|
||||
ImGui::SetNextWindowSize(ImVec2(400,400), ImGuiSetCond_FirstUseEver);
|
||||
ImGui::SetNextWindowSize(ImVec2(400,400), ImGuiCond_FirstUseEver);
|
||||
ImGui::Begin("Debug");
|
||||
}
|
||||
|
||||
@ -3776,20 +3794,13 @@ void ImGui::RenderCheckMark(ImVec2 pos, ImU32 col)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
|
||||
ImVec2 a, b, c;
|
||||
float start_x = (float)(int)(g.FontSize * 0.307f + 0.5f);
|
||||
float rem_third = (float)(int)((g.FontSize - start_x) / 3.0f);
|
||||
a.x = pos.x + 0.5f + start_x;
|
||||
b.x = a.x + rem_third;
|
||||
c.x = a.x + rem_third * 3.0f;
|
||||
b.y = pos.y - 1.0f + (float)(int)(g.Font->Ascent * (g.FontSize / g.Font->FontSize) + 0.5f) + (float)(int)(g.Font->DisplayOffset.y);
|
||||
a.y = b.y - rem_third;
|
||||
c.y = b.y - rem_third * 2.0f;
|
||||
|
||||
window->DrawList->PathLineTo(a);
|
||||
window->DrawList->PathLineTo(b);
|
||||
window->DrawList->PathLineTo(c);
|
||||
float bx = pos.x + 0.5f + start_x + rem_third;
|
||||
float by = pos.y - 1.0f + (float)(int)(g.Font->Ascent * (g.FontSize / g.Font->FontSize) + 0.5f) + (float)(int)(g.Font->DisplayOffset.y);
|
||||
window->DrawList->PathLineTo(ImVec2(bx - rem_third, by - rem_third));
|
||||
window->DrawList->PathLineTo(ImVec2(bx, by));
|
||||
window->DrawList->PathLineTo(ImVec2(bx + rem_third*2, by - rem_third*2));
|
||||
window->DrawList->PathStroke(col, false);
|
||||
}
|
||||
|
||||
@ -4635,9 +4646,9 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl
|
||||
}
|
||||
else
|
||||
{
|
||||
window->SetWindowPosAllowFlags &= ~ImGuiSetCond_FirstUseEver;
|
||||
window->SetWindowSizeAllowFlags &= ~ImGuiSetCond_FirstUseEver;
|
||||
window->SetWindowCollapsedAllowFlags &= ~ImGuiSetCond_FirstUseEver;
|
||||
window->SetWindowPosAllowFlags &= ~ImGuiCond_FirstUseEver;
|
||||
window->SetWindowSizeAllowFlags &= ~ImGuiCond_FirstUseEver;
|
||||
window->SetWindowCollapsedAllowFlags &= ~ImGuiCond_FirstUseEver;
|
||||
}
|
||||
|
||||
if (settings->Pos.x != FLT_MAX)
|
||||
@ -4722,7 +4733,7 @@ static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window)
|
||||
// You can use the "##" or "###" markers to use the same label with different id, or same id with different label. See documentation at the top of this file.
|
||||
// - Return false when window is collapsed, so you can early out in your code. You always need to call ImGui::End() even if false is returned.
|
||||
// - Passing 'bool* p_open' displays a Close button on the upper-right corner of the window, the pointed value will be set to false when the button is pressed.
|
||||
// - Passing non-zero 'size' is roughly equivalent to calling SetNextWindowSize(size, ImGuiSetCond_FirstUseEver) prior to calling Begin().
|
||||
// - Passing non-zero 'size' is roughly equivalent to calling SetNextWindowSize(size, ImGuiCond_FirstUseEver) prior to calling Begin().
|
||||
bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
{
|
||||
return ImGui::Begin(name, p_open, ImVec2(0.f, 0.f), -1.0f, flags);
|
||||
@ -4785,12 +4796,12 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
|
||||
if (g.SetNextWindowPosCond)
|
||||
{
|
||||
const ImVec2 backup_cursor_pos = window->DC.CursorPos; // FIXME: not sure of the exact reason of this saving/restore anymore :( need to look into that.
|
||||
if (!window_was_active || window_appearing_after_being_hidden) window->SetWindowPosAllowFlags |= ImGuiSetCond_Appearing;
|
||||
if (!window_was_active || window_appearing_after_being_hidden) window->SetWindowPosAllowFlags |= ImGuiCond_Appearing;
|
||||
window_pos_set_by_api = (window->SetWindowPosAllowFlags & g.SetNextWindowPosCond) != 0;
|
||||
if (window_pos_set_by_api && ImLengthSqr(g.SetNextWindowPosVal - ImVec2(-FLT_MAX,-FLT_MAX)) < 0.001f)
|
||||
{
|
||||
window->SetWindowPosCenterWanted = true; // May be processed on the next frame if this is our first frame and we are measuring size
|
||||
window->SetWindowPosAllowFlags &= ~(ImGuiSetCond_Once | ImGuiSetCond_FirstUseEver | ImGuiSetCond_Appearing);
|
||||
window->SetWindowPosAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -4801,7 +4812,7 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
|
||||
}
|
||||
if (g.SetNextWindowSizeCond)
|
||||
{
|
||||
if (!window_was_active || window_appearing_after_being_hidden) window->SetWindowSizeAllowFlags |= ImGuiSetCond_Appearing;
|
||||
if (!window_was_active || window_appearing_after_being_hidden) window->SetWindowSizeAllowFlags |= ImGuiCond_Appearing;
|
||||
window_size_set_by_api = (window->SetWindowSizeAllowFlags & g.SetNextWindowSizeCond) != 0;
|
||||
SetWindowSize(window, g.SetNextWindowSizeVal, g.SetNextWindowSizeCond);
|
||||
g.SetNextWindowSizeCond = 0;
|
||||
@ -4817,7 +4828,7 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
|
||||
}
|
||||
if (g.SetNextWindowCollapsedCond)
|
||||
{
|
||||
if (!window_was_active || window_appearing_after_being_hidden) window->SetWindowCollapsedAllowFlags |= ImGuiSetCond_Appearing;
|
||||
if (!window_was_active || window_appearing_after_being_hidden) window->SetWindowCollapsedAllowFlags |= ImGuiCond_Appearing;
|
||||
SetWindowCollapsed(window, g.SetNextWindowCollapsedVal, g.SetNextWindowCollapsedCond);
|
||||
g.SetNextWindowCollapsedCond = 0;
|
||||
}
|
||||
@ -5854,12 +5865,12 @@ static void SetWindowScrollY(ImGuiWindow* window, float new_scroll_y)
|
||||
window->DC.CursorMaxPos.y -= window->Scroll.y;
|
||||
}
|
||||
|
||||
static void SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiSetCond cond)
|
||||
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;
|
||||
window->SetWindowPosAllowFlags &= ~(ImGuiSetCond_Once | ImGuiSetCond_FirstUseEver | ImGuiSetCond_Appearing);
|
||||
window->SetWindowPosAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing);
|
||||
window->SetWindowPosCenterWanted = false;
|
||||
|
||||
// Set
|
||||
@ -5870,13 +5881,13 @@ static void SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiSetCond co
|
||||
window->DC.CursorMaxPos += (window->Pos - old_pos); // And more importantly we need to adjust this so size calculation doesn't get affected.
|
||||
}
|
||||
|
||||
void ImGui::SetWindowPos(const ImVec2& pos, ImGuiSetCond cond)
|
||||
void ImGui::SetWindowPos(const ImVec2& pos, ImGuiCond cond)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindowRead();
|
||||
SetWindowPos(window, pos, cond);
|
||||
}
|
||||
|
||||
void ImGui::SetWindowPos(const char* name, const ImVec2& pos, ImGuiSetCond cond)
|
||||
void ImGui::SetWindowPos(const char* name, const ImVec2& pos, ImGuiCond cond)
|
||||
{
|
||||
if (ImGuiWindow* window = FindWindowByName(name))
|
||||
SetWindowPos(window, pos, cond);
|
||||
@ -5888,12 +5899,12 @@ ImVec2 ImGui::GetWindowSize()
|
||||
return window->Size;
|
||||
}
|
||||
|
||||
static void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiSetCond cond)
|
||||
static void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond cond)
|
||||
{
|
||||
// Test condition (NB: bit 0 is always true) and clear flags for next time
|
||||
if (cond && (window->SetWindowSizeAllowFlags & cond) == 0)
|
||||
return;
|
||||
window->SetWindowSizeAllowFlags &= ~(ImGuiSetCond_Once | ImGuiSetCond_FirstUseEver | ImGuiSetCond_Appearing);
|
||||
window->SetWindowSizeAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing);
|
||||
|
||||
// Set
|
||||
if (size.x > 0.0f)
|
||||
@ -5918,30 +5929,30 @@ static void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiSetCond
|
||||
}
|
||||
}
|
||||
|
||||
void ImGui::SetWindowSize(const ImVec2& size, ImGuiSetCond cond)
|
||||
void ImGui::SetWindowSize(const ImVec2& size, ImGuiCond cond)
|
||||
{
|
||||
SetWindowSize(GImGui->CurrentWindow, size, cond);
|
||||
}
|
||||
|
||||
void ImGui::SetWindowSize(const char* name, const ImVec2& size, ImGuiSetCond cond)
|
||||
void ImGui::SetWindowSize(const char* name, const ImVec2& size, ImGuiCond cond)
|
||||
{
|
||||
ImGuiWindow* window = FindWindowByName(name);
|
||||
if (window)
|
||||
SetWindowSize(window, size, cond);
|
||||
}
|
||||
|
||||
static void SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiSetCond cond)
|
||||
static void SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond cond)
|
||||
{
|
||||
// Test condition (NB: bit 0 is always true) and clear flags for next time
|
||||
if (cond && (window->SetWindowCollapsedAllowFlags & cond) == 0)
|
||||
return;
|
||||
window->SetWindowCollapsedAllowFlags &= ~(ImGuiSetCond_Once | ImGuiSetCond_FirstUseEver | ImGuiSetCond_Appearing);
|
||||
window->SetWindowCollapsedAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing);
|
||||
|
||||
// Set
|
||||
window->Collapsed = collapsed;
|
||||
}
|
||||
|
||||
void ImGui::SetWindowCollapsed(bool collapsed, ImGuiSetCond cond)
|
||||
void ImGui::SetWindowCollapsed(bool collapsed, ImGuiCond cond)
|
||||
{
|
||||
SetWindowCollapsed(GImGui->CurrentWindow, collapsed, cond);
|
||||
}
|
||||
@ -5951,7 +5962,7 @@ bool ImGui::IsWindowCollapsed()
|
||||
return GImGui->CurrentWindow->Collapsed;
|
||||
}
|
||||
|
||||
void ImGui::SetWindowCollapsed(const char* name, bool collapsed, ImGuiSetCond cond)
|
||||
void ImGui::SetWindowCollapsed(const char* name, bool collapsed, ImGuiCond cond)
|
||||
{
|
||||
ImGuiWindow* window = FindWindowByName(name);
|
||||
if (window)
|
||||
@ -5976,25 +5987,25 @@ void ImGui::SetWindowFocus(const char* name)
|
||||
}
|
||||
}
|
||||
|
||||
void ImGui::SetNextWindowPos(const ImVec2& pos, ImGuiSetCond cond)
|
||||
void ImGui::SetNextWindowPos(const ImVec2& pos, ImGuiCond cond)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.SetNextWindowPosVal = pos;
|
||||
g.SetNextWindowPosCond = cond ? cond : ImGuiSetCond_Always;
|
||||
g.SetNextWindowPosCond = cond ? cond : ImGuiCond_Always;
|
||||
}
|
||||
|
||||
void ImGui::SetNextWindowPosCenter(ImGuiSetCond cond)
|
||||
void ImGui::SetNextWindowPosCenter(ImGuiCond cond)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.SetNextWindowPosVal = ImVec2(-FLT_MAX, -FLT_MAX);
|
||||
g.SetNextWindowPosCond = cond ? cond : ImGuiSetCond_Always;
|
||||
g.SetNextWindowPosCond = cond ? cond : ImGuiCond_Always;
|
||||
}
|
||||
|
||||
void ImGui::SetNextWindowSize(const ImVec2& size, ImGuiSetCond cond)
|
||||
void ImGui::SetNextWindowSize(const ImVec2& size, ImGuiCond cond)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.SetNextWindowSizeVal = size;
|
||||
g.SetNextWindowSizeCond = cond ? cond : ImGuiSetCond_Always;
|
||||
g.SetNextWindowSizeCond = cond ? cond : ImGuiCond_Always;
|
||||
}
|
||||
|
||||
void ImGui::SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeConstraintCallback custom_callback, void* custom_callback_user_data)
|
||||
@ -6010,21 +6021,21 @@ void ImGui::SetNextWindowContentSize(const ImVec2& size)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.SetNextWindowContentSizeVal = size;
|
||||
g.SetNextWindowContentSizeCond = ImGuiSetCond_Always;
|
||||
g.SetNextWindowContentSizeCond = ImGuiCond_Always;
|
||||
}
|
||||
|
||||
void ImGui::SetNextWindowContentWidth(float width)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.SetNextWindowContentSizeVal = ImVec2(width, g.SetNextWindowContentSizeCond ? g.SetNextWindowContentSizeVal.y : 0.0f);
|
||||
g.SetNextWindowContentSizeCond = ImGuiSetCond_Always;
|
||||
g.SetNextWindowContentSizeCond = ImGuiCond_Always;
|
||||
}
|
||||
|
||||
void ImGui::SetNextWindowCollapsed(bool collapsed, ImGuiSetCond cond)
|
||||
void ImGui::SetNextWindowCollapsed(bool collapsed, ImGuiCond cond)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.SetNextWindowCollapsedVal = collapsed;
|
||||
g.SetNextWindowCollapsedCond = cond ? cond : ImGuiSetCond_Always;
|
||||
g.SetNextWindowCollapsedCond = cond ? cond : ImGuiCond_Always;
|
||||
}
|
||||
|
||||
void ImGui::SetNextWindowFocus()
|
||||
@ -6879,14 +6890,14 @@ bool ImGui::TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags)
|
||||
bool is_open;
|
||||
if (g.SetNextTreeNodeOpenCond != 0)
|
||||
{
|
||||
if (g.SetNextTreeNodeOpenCond & ImGuiSetCond_Always)
|
||||
if (g.SetNextTreeNodeOpenCond & ImGuiCond_Always)
|
||||
{
|
||||
is_open = g.SetNextTreeNodeOpenVal;
|
||||
storage->SetInt(id, is_open);
|
||||
}
|
||||
else
|
||||
{
|
||||
// We treat ImGuiSetCondition_Once and ImGuiSetCondition_FirstUseEver the same because tree node state are not saved persistently.
|
||||
// We treat ImGuiCond_Once and ImGuiCond_FirstUseEver the same because tree node state are not saved persistently.
|
||||
const int stored_value = storage->GetInt(id, -1);
|
||||
if (stored_value == -1)
|
||||
{
|
||||
@ -7153,11 +7164,11 @@ float ImGui::GetTreeNodeToLabelSpacing()
|
||||
return g.FontSize + (g.Style.FramePadding.x * 2.0f);
|
||||
}
|
||||
|
||||
void ImGui::SetNextTreeNodeOpen(bool is_open, ImGuiSetCond cond)
|
||||
void ImGui::SetNextTreeNodeOpen(bool is_open, ImGuiCond cond)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.SetNextTreeNodeOpenVal = is_open;
|
||||
g.SetNextTreeNodeOpenCond = cond ? cond : ImGuiSetCond_Always;
|
||||
g.SetNextTreeNodeOpenCond = cond ? cond : ImGuiCond_Always;
|
||||
}
|
||||
|
||||
void ImGui::PushID(const char* str_id)
|
||||
@ -10029,7 +10040,7 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
|
||||
|
||||
if (menu_is_open)
|
||||
{
|
||||
SetNextWindowPos(popup_pos, ImGuiSetCond_Always);
|
||||
SetNextWindowPos(popup_pos, ImGuiCond_Always);
|
||||
ImGuiWindowFlags flags = ImGuiWindowFlags_ShowBorders | ((window->Flags & (ImGuiWindowFlags_Popup|ImGuiWindowFlags_ChildMenu)) ? ImGuiWindowFlags_ChildMenu|ImGuiWindowFlags_ChildWindow : ImGuiWindowFlags_ChildMenu);
|
||||
menu_is_open = BeginPopupEx(label, flags); // menu_is_open can be 'false' when the popup is completely clipped (e.g. zero size display)
|
||||
}
|
||||
@ -10493,20 +10504,19 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
||||
PushID(label);
|
||||
BeginGroup();
|
||||
|
||||
if ((flags & ImGuiColorEditFlags_NoSidePreview) == 0)
|
||||
if (!(flags & ImGuiColorEditFlags_NoSidePreview))
|
||||
flags |= ImGuiColorEditFlags_NoSmallPreview;
|
||||
|
||||
if ((flags & ImGuiColorEditFlags_NoOptions) == 0)
|
||||
{
|
||||
// Context menu: display and store options.
|
||||
// Context menu: display and store options.
|
||||
if (!(flags & ImGuiColorEditFlags_NoOptions))
|
||||
ColorPickerOptionsPopup(flags, col);
|
||||
|
||||
// Read stored options
|
||||
if ((flags & ImGuiColorEditFlags__PickerMask) == 0)
|
||||
flags |= ((g.ColorEditOptions & ImGuiColorEditFlags__PickerMask) ? g.ColorEditOptions : ImGuiColorEditFlags__OptionsDefault) & ImGuiColorEditFlags__PickerMask;
|
||||
IM_ASSERT(ImIsPowerOfTwo((int)(flags & ImGuiColorEditFlags__PickerMask))); // Check that only 1 is selected
|
||||
// Read stored options
|
||||
if (!(flags & ImGuiColorEditFlags__PickerMask))
|
||||
flags |= ((g.ColorEditOptions & ImGuiColorEditFlags__PickerMask) ? g.ColorEditOptions : ImGuiColorEditFlags__OptionsDefault) & ImGuiColorEditFlags__PickerMask;
|
||||
IM_ASSERT(ImIsPowerOfTwo((int)(flags & ImGuiColorEditFlags__PickerMask))); // Check that only 1 is selected
|
||||
if (!(flags & ImGuiColorEditFlags_NoOptions))
|
||||
flags |= (g.ColorEditOptions & ImGuiColorEditFlags_AlphaBar);
|
||||
}
|
||||
|
||||
// Setup
|
||||
bool alpha_bar = (flags & ImGuiColorEditFlags_AlphaBar) && !(flags & ImGuiColorEditFlags_NoAlpha);
|
||||
@ -10648,7 +10658,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
||||
if ((flags & ImGuiColorEditFlags_NoInputs) == 0)
|
||||
{
|
||||
PushItemWidth((alpha_bar ? bar1_pos_x : bar0_pos_x) + bars_width - picker_pos.x);
|
||||
ImGuiColorEditFlags sub_flags_to_forward = ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoSmallPreview | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf;
|
||||
ImGuiColorEditFlags sub_flags_to_forward = ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoOptions | ImGuiColorEditFlags_NoSmallPreview | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf;
|
||||
ImGuiColorEditFlags sub_flags = (flags & sub_flags_to_forward) | ImGuiColorEditFlags_NoPicker;
|
||||
if (flags & ImGuiColorEditFlags_RGB || (flags & ImGuiColorEditFlags__InputsMask) == 0)
|
||||
value_changed |= ColorEdit4("##rgb", col, sub_flags | ImGuiColorEditFlags_RGB);
|
||||
@ -11222,21 +11232,6 @@ void ImGui::Value(const char* prefix, float v, const char* float_format)
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: May want to remove those helpers?
|
||||
void ImGui::ValueColor(const char* prefix, const ImVec4& v)
|
||||
{
|
||||
Text("%s: (%.2f,%.2f,%.2f,%.2f)", prefix, v.x, v.y, v.z, v.w);
|
||||
SameLine();
|
||||
ColorButton(prefix, v);
|
||||
}
|
||||
|
||||
void ImGui::ValueColor(const char* prefix, ImU32 v)
|
||||
{
|
||||
Text("%s: %08X", prefix, v);
|
||||
SameLine();
|
||||
ColorButton(prefix, ColorConvertU32ToFloat4(v));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// PLATFORM DEPENDENT HELPERS
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -11470,7 +11465,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
ImGui::Text("HoveredRootWindow: '%s'", g.HoveredRootWindow ? g.HoveredRootWindow->Name : "NULL");
|
||||
ImGui::Text("HoveredId: 0x%08X/0x%08X", g.HoveredId, g.HoveredIdPreviousFrame); // Data is "in-flight" so depending on when the Metrics window is called we may see current frame information or not
|
||||
ImGui::Text("ActiveId: 0x%08X/0x%08X, ActiveIdSource: %s", g.ActiveId, g.ActiveIdPreviousFrame, input_source_names[g.ActiveIdSource]);
|
||||
ImGui::Text("ActiveIdWindow: '%s", g.ActiveIdWindow ? g.ActiveIdWindow->Name : "NULL");
|
||||
ImGui::Text("ActiveIdWindow: '%s'", g.ActiveIdWindow ? g.ActiveIdWindow->Name : "NULL");
|
||||
ImGui::Text("NavWindow: '%s', NavId: 0x%08X, NavLayer: %d", g.NavWindow ? g.NavWindow->Name : "NULL", g.NavId, g.NavLayer);
|
||||
ImGui::Text("NavRefRectRel: (%.1f,%.1f)(%.1f,%.1f)", g.NavRefRectRel.Min.x, g.NavRefRectRel.Min.y, g.NavRefRectRel.Max.x, g.NavRefRectRel.Max.y);
|
||||
ImGui::Text("NavUsable: %d, NavActive: %d", g.IO.NavUsable, g.IO.NavActive);
|
||||
|
Reference in New Issue
Block a user