mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-28 09:30:56 +01:00
Merge branch 'master' into navigation
# Conflicts: # imgui.cpp # imgui_demo.cpp
This commit is contained in:
commit
d500113f1d
@ -153,10 +153,9 @@ I occasionally tag [Releases](https://github.com/ocornut/imgui/releases) but it
|
||||
|
||||
The library started its life and is best known as "ImGui" only due to the fact that I didn't give it a proper name when I released it. However, the term IMGUI (immediate-mode graphical user interface) was coined before and is being used in variety of other situations. It seemed confusing and unfair to hog the name. To reduce the ambiguity without affecting existing codebases, I have decided on an alternate, longer name "dear imgui" that people can use to refer to this specific library in ambiguous situations.
|
||||
|
||||
<b>What is ImTextureID and how do I display an image?</b>
|
||||
<br><b>I integrated Dear ImGui in my engine and the text or lines are blurry..</b>
|
||||
<br><b>I integrated Dear ImGui in my engine and some elements are disappearing when I move windows around..</b>
|
||||
<br><b>How can I have multiple widgets with the same label? Can I have widget without a label? (Yes). A primer on labels/IDs.</b>
|
||||
<b>How can I help</b>
|
||||
<br><b>How can I display an image? What is ImTextureID, how does it works?</b>
|
||||
<br><b>How can I have multiple widgets with the same label? Can I have widget without a label? (Yes). A primer on labels and the ID stack.</b>
|
||||
<br><b>How can I tell when Dear ImGui wants my mouse/keyboard inputs VS when I can pass them to my application?</b>
|
||||
<br><b>How can I load a different font than the default?</b>
|
||||
<br><b>How can I easily use icons in my application?</b>
|
||||
@ -164,6 +163,8 @@ The library started its life and is best known as "ImGui" only due to the fact t
|
||||
<br><b>How can I display and input non-latin characters such as Chinese, Japanese, Korean, Cyrillic?</b>
|
||||
<br><b>How can I preserve my Dear ImGui context across reloading a DLL? (loss of the global/static variables)</b>
|
||||
<br><b>How can I use the drawing facilities without an Dear ImGui window? (using ImDrawList API)</b>
|
||||
<br><b>I integrated Dear ImGui in my engine and the text or lines are blurry..</b>
|
||||
<br><b>I integrated Dear ImGui in my engine and some elements are disappearing when I move windows around..</b>
|
||||
|
||||
See the FAQ in imgui.cpp for answers.
|
||||
|
||||
|
124
imgui.cpp
124
imgui.cpp
@ -27,10 +27,8 @@
|
||||
- ISSUES & TODO LIST
|
||||
- FREQUENTLY ASKED QUESTIONS (FAQ), TIPS
|
||||
- How can I help?
|
||||
- What is ImTextureID and how do I display an image?
|
||||
- I integrated Dear ImGui in my engine and the text or lines are blurry..
|
||||
- I integrated Dear 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 labels/IDs.
|
||||
- How can I dipslay an image? What is ImTextureID, how does it works?
|
||||
- How can I have multiple widgets with the same label? Can I have widget without a label? (Yes). A primer on labels and the ID stack.
|
||||
- How can I tell when Dear 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?
|
||||
@ -38,6 +36,8 @@
|
||||
- How can I display and input non-latin characters such as Chinese, Japanese, Korean, Cyrillic?
|
||||
- How can I preserve my Dear 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)
|
||||
- I integrated Dear ImGui in my engine and the text or lines are blurry..
|
||||
- I integrated Dear ImGui in my engine and some elements are clipping or disappearing when I move windows around..
|
||||
- ISSUES & TODO-LIST
|
||||
- CODE
|
||||
|
||||
@ -410,10 +410,14 @@
|
||||
======================================
|
||||
|
||||
Q: How can I help?
|
||||
A: - If you are experienced enough with Dear ImGui and with C/C++, look at the todo list and see how you want/can help!
|
||||
- Become a Patron/donate! Convince your company to become a Patron or provide serious funding for development time! See http://www.patreon.com/imgui
|
||||
A: - If you are experienced with Dear ImGui and C++, look at the github issues, or TODO.txt and see how you want/can help!
|
||||
- Convince your company to fund development time! Individual users: you can also become a Patron (patreon.com/imgui) or donate on PayPal! See README.
|
||||
- Disclose your usage of dear imgui via a dev blog post, a tweet, a screenshot, a mention somewhere etc.
|
||||
You may post screenshot or links in the gallery threads (github.com/ocornut/imgui/issues/1269). Visuals are ideal as they inspire other programmers.
|
||||
But even without visuals, disclosing your use of dear imgui help the library grow credibility, and help other teams and programmers with taking decisions.
|
||||
- If you have issues or if you need to hack into the library, even if you don't expect any support it is useful that you share your issues (on github or privately).
|
||||
|
||||
Q: What is ImTextureID and how do I display an image?
|
||||
Q: How can I display an image? What is ImTextureID, how does it works?
|
||||
A: ImTextureID is a void* used to pass renderer-agnostic texture references around until it hits your render function.
|
||||
Dear ImGui knows nothing about what those bits represent, it just passes them around. It is up to you to decide what you want the void* to carry!
|
||||
It could be an identifier to your OpenGL texture (cast GLuint to void*), a pointer to your custom engine material (cast MyMaterial* to void*), etc.
|
||||
@ -422,26 +426,19 @@
|
||||
(c++ tip: OpenGL uses integers to identify textures. You can safely store an integer into a void*, just cast it to void*, don't take it's address!)
|
||||
To display a custom image/texture within an ImGui window, you may use ImGui::Image(), ImGui::ImageButton(), ImDrawList::AddImage() functions.
|
||||
Dear ImGui will generate the geometry and draw calls using the ImTextureID that you passed and which your renderer can use.
|
||||
You may call ImGui::ShowMetricsWindow() to explore active draw lists and visualize/understand how the draw data is generated.
|
||||
It is your responsibility to get textures uploaded to your GPU.
|
||||
|
||||
Q: I integrated Dear ImGui in my engine and the text or lines are blurry..
|
||||
A: In your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f).
|
||||
Also make sure your orthographic projection matrix and io.DisplaySize matches your actual framebuffer dimension.
|
||||
|
||||
Q: I integrated Dear ImGui in my engine and some elements are clipping or disappearing when I move windows around..
|
||||
A: You are probably mishandling the clipping rectangles in your render function.
|
||||
Rectangles provided by ImGui are defined as (x1=left,y1=top,x2=right,y2=bottom) and NOT as (x1,y1,width,height).
|
||||
|
||||
Q: Can I have multiple widgets with the same label? Can I have widget without a label?
|
||||
A: Yes. A primer on the use of labels/IDs in Dear ImGui..
|
||||
A: Yes. A primer on labels and the ID stack...
|
||||
|
||||
- Elements that are not clickable, such as Text() items don't need an ID.
|
||||
- Elements that are typically not clickable, such as Text() items don't need an ID.
|
||||
|
||||
- Interactive widgets require state to be carried over multiple frames (most typically Dear ImGui often needs to remember what is
|
||||
the "active" widget). to do so they need a unique ID. unique ID are typically derived from a string label, an integer index or a pointer.
|
||||
|
||||
Button("OK"); // Label = "OK", ID = hash of "OK"
|
||||
Button("Cancel"); // Label = "Cancel", ID = hash of "Cancel"
|
||||
Button("OK"); // Label = "OK", ID = hash of "OK"
|
||||
Button("Cancel"); // Label = "Cancel", ID = hash of "Cancel"
|
||||
|
||||
- ID are uniquely scoped within windows, tree nodes, etc. so no conflict can happen if you have two buttons called "OK"
|
||||
in two different windows or in two different locations of a tree.
|
||||
@ -449,34 +446,35 @@
|
||||
- If you have a same ID twice in the same location, you'll have a conflict:
|
||||
|
||||
Button("OK");
|
||||
Button("OK"); // ID collision! Both buttons will be treated as the same.
|
||||
Button("OK"); // ID collision! Both buttons will be treated as the same.
|
||||
|
||||
Fear not! this is easy to solve and there are many ways to solve it!
|
||||
|
||||
- When passing a label you can optionally specify extra unique ID information within string itself.
|
||||
This helps solving the simpler collision cases. Use "##" to pass a complement to the ID that won't be visible to the end-user:
|
||||
- When passing a label you can optionally specify extra unique ID information within string itself.
|
||||
Use "##" to pass a complement to the ID that won't be visible to the end-user.
|
||||
This helps solving the simple collision cases when you know which items are going to be created.
|
||||
|
||||
Button("Play"); // Label = "Play", ID = hash of "Play"
|
||||
Button("Play##foo1"); // Label = "Play", ID = hash of "Play##foo1" (different from above)
|
||||
Button("Play##foo2"); // Label = "Play", ID = hash of "Play##foo2" (different from above)
|
||||
Button("Play"); // Label = "Play", ID = hash of "Play"
|
||||
Button("Play##foo1"); // Label = "Play", ID = hash of "Play##foo1" (different from above)
|
||||
Button("Play##foo2"); // Label = "Play", ID = hash of "Play##foo2" (different from above)
|
||||
|
||||
- If you want to completely hide the label, but still need an ID:
|
||||
|
||||
Checkbox("##On", &b); // Label = "", ID = hash of "##On" (no label!)
|
||||
Checkbox("##On", &b); // Label = "", ID = hash of "##On" (no label!)
|
||||
|
||||
- Occasionally/rarely you might want change a label while preserving a constant ID. This allows you to animate labels.
|
||||
For example you may want to include varying information in a window title bar (and windows are uniquely identified by their ID.. obviously)
|
||||
For example you may want to include varying information in a window title bar, but windows are uniquely identified by their ID..
|
||||
Use "###" to pass a label that isn't part of ID:
|
||||
|
||||
Button("Hello###ID"; // Label = "Hello", ID = hash of "ID"
|
||||
Button("World###ID"; // Label = "World", ID = hash of "ID" (same as above)
|
||||
|
||||
sprintf(buf, "My game (%f FPS)###MyGame");
|
||||
sprintf(buf, "My game (%f FPS)###MyGame", fps);
|
||||
Begin(buf); // Variable label, ID = hash of "MyGame"
|
||||
|
||||
- Use PushID() / PopID() to create scopes and avoid ID conflicts within the same Window.
|
||||
This is the most convenient way of distinguishing ID if you are iterating and creating many UI elements.
|
||||
You can push a pointer, a string or an integer value. Remember that ID are formed from the concatenation of everything in the ID stack!
|
||||
You can push a pointer, a string or an integer value. Remember that ID are formed from the concatenation of _everything_ in the ID stack!
|
||||
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
@ -606,16 +604,25 @@
|
||||
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.
|
||||
A: - You can create a dummy window. Call Begin() with NoTitleBar|NoResize|NoMove|NoScrollbar|NoSavedSettings|NoInputs flag,
|
||||
push a ImGuiCol_WindowBg with zero alpha, then retrieve the ImDrawList* via GetWindowDrawList() and draw to it in any way you like.
|
||||
- You can call ImGui::GetOverlayDrawList() and use this draw list to display contents over every other imgui windows.
|
||||
- You can create your own ImDrawList instance. You'll need to initialize them ImGui::GetDrawListSharedData(), or create your own ImDrawListSharedData.
|
||||
|
||||
Q: I integrated Dear ImGui in my engine and the text or lines are blurry..
|
||||
A: In your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f).
|
||||
Also make sure your orthographic projection matrix and io.DisplaySize matches your actual framebuffer dimension.
|
||||
|
||||
Q: I integrated Dear ImGui in my engine and some elements are clipping or disappearing when I move windows around..
|
||||
A: You are probably mishandling the clipping rectangles in your render function.
|
||||
Rectangles provided by ImGui are defined as (x1=left,y1=top,x2=right,y2=bottom) and NOT as (x1,y1,width,height).
|
||||
|
||||
|
||||
- tip: you can call Begin() multiple times with the same name during the same frame, it will keep appending to the same window.
|
||||
this is also useful to set yourself in the context of another window (to get/set other settings)
|
||||
this is also useful to set yourself in the context of another window (to get/set other settings)
|
||||
- tip: you can create widgets without a Begin()/End() block, they will go in an implicit window called "Debug".
|
||||
- tip: the ImGuiOnceUponAFrame helper will allow 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.
|
||||
of a deep nested inner loop in your code.
|
||||
- tip: you can call Render() multiple times (e.g for VR renders).
|
||||
- tip: call and read the ShowDemoWindow() code in imgui_demo.cpp for more example of how to use ImGui!
|
||||
|
||||
@ -3180,11 +3187,10 @@ void ImGui::NewFrame()
|
||||
g.IO.Framerate = 1.0f / (g.FramerateSecPerFrameAccum / (float)IM_ARRAYSIZE(g.FramerateSecPerFrame));
|
||||
|
||||
// Handle user moving window with mouse (at the beginning of the frame to avoid input lag or sheering).
|
||||
if (g.MovingWindowMoveId && g.MovingWindowMoveId == g.ActiveId && g.ActiveIdSource == ImGuiInputSource_Mouse)
|
||||
if (g.MovingWindow && g.MovingWindow->MoveId == g.ActiveId && g.ActiveIdSource == ImGuiInputSource_Mouse)
|
||||
{
|
||||
KeepAliveID(g.ActiveId);
|
||||
IM_ASSERT(g.MovingWindow && g.MovingWindow->RootWindow);
|
||||
IM_ASSERT(g.MovingWindow->MoveId == g.MovingWindowMoveId);
|
||||
if (g.IO.MouseDown[0])
|
||||
{
|
||||
// MovingWindow = window we clicked on, could be a child window. We track it to preserve Focus and so that ActiveIdWindow == MovingWindow and ActiveId == MovingWindow->MoveId for consistency.
|
||||
@ -3201,7 +3207,6 @@ void ImGui::NewFrame()
|
||||
{
|
||||
ClearActiveID();
|
||||
g.MovingWindow = NULL;
|
||||
g.MovingWindowMoveId = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -3214,7 +3219,6 @@ void ImGui::NewFrame()
|
||||
ClearActiveID();
|
||||
}
|
||||
g.MovingWindow = NULL;
|
||||
g.MovingWindowMoveId = 0;
|
||||
}
|
||||
|
||||
// Delay saving settings so we don't spam disk too much
|
||||
@ -3787,10 +3791,7 @@ void ImGui::EndFrame()
|
||||
SetActiveID(g.HoveredWindow->MoveId, g.HoveredWindow);
|
||||
g.ActiveIdClickOffset = g.IO.MousePos - g.HoveredRootWindow->Pos;
|
||||
if (!(g.HoveredWindow->Flags & ImGuiWindowFlags_NoMove) && !(g.HoveredRootWindow->Flags & ImGuiWindowFlags_NoMove))
|
||||
{
|
||||
g.MovingWindow = g.HoveredWindow;
|
||||
g.MovingWindowMoveId = g.MovingWindow->MoveId;
|
||||
}
|
||||
|
||||
// FIXME-NAV: This never execute because of the FocusWindow call above, however we may want this behavior?
|
||||
/*
|
||||
@ -4772,6 +4773,7 @@ bool ImGui::BeginPopupModal(const char* name, bool* p_open, ImGuiWindowFlags fla
|
||||
}
|
||||
|
||||
// Center modal windows by default
|
||||
// FIXME: Should test for (PosCond & window->SetWindowPosAllowFlags) with the upcoming window.
|
||||
if (g.NextWindowData.PosCond == 0)
|
||||
SetNextWindowPos(g.IO.DisplaySize * 0.5f, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
|
||||
|
||||
@ -5727,8 +5729,10 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
}
|
||||
else
|
||||
{
|
||||
// Window background, Default Alpha
|
||||
// Window background
|
||||
ImU32 bg_col = GetColorU32(GetWindowBgColorIdxFromFlags(flags));
|
||||
if (g.NextWindowData.BgAlphaCond != 0)
|
||||
bg_col = (bg_col & ~IM_COL32_A_MASK) | (IM_F32_TO_INT8_SAT(g.NextWindowData.BgAlphaVal) << IM_COL32_A_SHIFT);
|
||||
window->DrawList->AddRectFilled(window->Pos+ImVec2(0,window->TitleBarHeight()), window->Pos+window->Size, bg_col, window_rounding, (flags & ImGuiWindowFlags_NoTitleBar) ? ImDrawCornerFlags_All : ImDrawCornerFlags_Bot);
|
||||
|
||||
// Title bar
|
||||
@ -5957,22 +5961,12 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
|
||||
{
|
||||
// Old API feature: we could pass the initial window size as a parameter, however this was very misleading because in most cases it would only affect the window when it didn't have storage in the .ini file.
|
||||
if (size_on_first_use.x != 0.0f || size_on_first_use.y != 0.0f)
|
||||
SetNextWindowSize(size_on_first_use, ImGuiCond_FirstUseEver);
|
||||
ImGui::SetNextWindowSize(size_on_first_use, ImGuiCond_FirstUseEver);
|
||||
|
||||
// Old API feature: we could override the window background alpha with a parameter. This is actually tricky to reproduce manually because:
|
||||
// (1) there are multiple variants of WindowBg (popup, tooltip, etc.) and (2) you can't call PushStyleColor before Begin and PopStyleColor just after Begin() because of how CheckStackSizes() behave.
|
||||
// The user-side solution is to do backup = GetStyleColorVec4(ImGuiCol_xxxBG), PushStyleColor(ImGuiCol_xxxBg), Begin, PushStyleColor(ImGuiCol_xxxBg, backup), [...], PopStyleColor(), End(); PopStyleColor() - which is super awkward.
|
||||
// The alpha override was rarely used but for now we'll leave the Begin() variant around for a bit. We may either lift the constraint on CheckStackSizes() either add a SetNextWindowBgAlpha() helper that does it magically.
|
||||
ImGuiContext& g = *GImGui;
|
||||
const ImGuiCol bg_color_idx = GetWindowBgColorIdxFromFlags(flags);
|
||||
const ImVec4 bg_color_backup = g.Style.Colors[bg_color_idx];
|
||||
if (bg_alpha_override >= 0.0f)
|
||||
g.Style.Colors[bg_color_idx].w = bg_alpha_override;
|
||||
// Old API feature: override the window background alpha with a parameter.
|
||||
ImGui::SetNextWindowBgAlpha(bg_alpha_override);
|
||||
|
||||
bool ret = Begin(name, p_open, flags);
|
||||
|
||||
if (bg_alpha_override >= 0.0f)
|
||||
g.Style.Colors[bg_color_idx] = bg_color_backup;
|
||||
bool ret = ImGui::Begin(name, p_open, flags);
|
||||
return ret;
|
||||
}
|
||||
#endif // IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
@ -6355,13 +6349,14 @@ struct ImGuiStyleVarInfo
|
||||
void* GetVarPtr(ImGuiStyle* style) const { return (void*)((unsigned char*)style + Offset); }
|
||||
};
|
||||
|
||||
static const ImGuiStyleVarInfo GStyleVarInfo[ImGuiStyleVar_Count_] =
|
||||
static const ImGuiStyleVarInfo GStyleVarInfo[] =
|
||||
{
|
||||
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, Alpha) }, // ImGuiStyleVar_Alpha
|
||||
{ ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowPadding) }, // ImGuiStyleVar_WindowPadding
|
||||
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowRounding) }, // ImGuiStyleVar_WindowRounding
|
||||
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowBorderSize) }, // ImGuiStyleVar_WindowBorderSize
|
||||
{ ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowMinSize) }, // ImGuiStyleVar_WindowMinSize
|
||||
{ ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowTitleAlign) }, // ImGuiStyleVar_WindowTitleAlign
|
||||
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, ChildRounding) }, // ImGuiStyleVar_ChildRounding
|
||||
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, ChildBorderSize) }, // ImGuiStyleVar_ChildBorderSize
|
||||
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, PopupRounding) }, // ImGuiStyleVar_PopupRounding
|
||||
@ -6372,13 +6367,17 @@ static const ImGuiStyleVarInfo GStyleVarInfo[ImGuiStyleVar_Count_] =
|
||||
{ ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemSpacing) }, // ImGuiStyleVar_ItemSpacing
|
||||
{ ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemInnerSpacing) }, // ImGuiStyleVar_ItemInnerSpacing
|
||||
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, IndentSpacing) }, // ImGuiStyleVar_IndentSpacing
|
||||
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, ScrollbarSize) }, // ImGuiStyleVar_ScrollbarSize
|
||||
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, ScrollbarRounding) }, // ImGuiStyleVar_ScrollbarRounding
|
||||
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, GrabMinSize) }, // ImGuiStyleVar_GrabMinSize
|
||||
{ ImGuiDataType_Float, (ImU32)IM_OFFSETOF(ImGuiStyle, GrabRounding) }, // ImGuiStyleVar_GrabRounding
|
||||
{ ImGuiDataType_Float2, (ImU32)IM_OFFSETOF(ImGuiStyle, ButtonTextAlign) }, // ImGuiStyleVar_ButtonTextAlign
|
||||
};
|
||||
|
||||
static const ImGuiStyleVarInfo* GetStyleVarInfo(ImGuiStyleVar idx)
|
||||
{
|
||||
IM_ASSERT(idx >= 0 && idx < ImGuiStyleVar_Count_);
|
||||
IM_ASSERT(IM_ARRAYSIZE(GStyleVarInfo) == ImGuiStyleVar_Count_);
|
||||
return &GStyleVarInfo[idx];
|
||||
}
|
||||
|
||||
@ -6756,7 +6755,14 @@ void ImGui::SetNextWindowCollapsed(bool collapsed, ImGuiCond cond)
|
||||
void ImGui::SetNextWindowFocus()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.NextWindowData.FocusCond = ImGuiCond_Always;
|
||||
g.NextWindowData.FocusCond = ImGuiCond_Always; // Using a Cond member for consistency (may transition all of them to single flag set for fast Clear() op)
|
||||
}
|
||||
|
||||
void ImGui::SetNextWindowBgAlpha(float alpha)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.NextWindowData.BgAlphaVal = alpha;
|
||||
g.NextWindowData.BgAlphaCond = ImGuiCond_Always; // Using a Cond member for consistency (may transition all of them to single flag set for fast Clear() op)
|
||||
}
|
||||
|
||||
// In window space (not screen space!)
|
||||
|
7
imgui.h
7
imgui.h
@ -173,6 +173,7 @@ namespace ImGui
|
||||
IMGUI_API void SetNextWindowContentSize(const ImVec2& size); // set next window content size (~ enforce the range of scrollbars). not including window decorations (title bar, menu bar, etc.). set an axis to 0.0f to leave it automatic. call before Begin()
|
||||
IMGUI_API void SetNextWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // set next window collapsed state. call before Begin()
|
||||
IMGUI_API void SetNextWindowFocus(); // set next window to be focused / front-most. call before Begin()
|
||||
IMGUI_API void SetNextWindowBgAlpha(float alpha); // set next window background color alpha. helper to easily modify ImGuiCol_WindowBg/ChildBg/PopupBg.
|
||||
IMGUI_API void SetWindowPos(const ImVec2& pos, ImGuiCond cond = 0); // (not recommended) set current window position - call within Begin()/End(). prefer using SetNextWindowPos(), as this may incur tearing and side-effects.
|
||||
IMGUI_API void SetWindowSize(const ImVec2& size, ImGuiCond cond = 0); // (not recommended) set current window size - call within Begin()/End(). set to ImVec2(0,0) to force an auto-fit. prefer using SetNextWindowSize(), as this may incur tearing and minor side-effects.
|
||||
IMGUI_API void SetWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // (not recommended) set current window collapsed state. prefer using SetNextWindowCollapsed().
|
||||
@ -789,6 +790,7 @@ enum ImGuiStyleVar_
|
||||
ImGuiStyleVar_WindowRounding, // float WindowRounding
|
||||
ImGuiStyleVar_WindowBorderSize, // float WindowBorderSize
|
||||
ImGuiStyleVar_WindowMinSize, // ImVec2 WindowMinSize
|
||||
ImGuiStyleVar_WindowTitleAlign, // ImVec2 WindowTitleAlign
|
||||
ImGuiStyleVar_ChildRounding, // float ChildRounding
|
||||
ImGuiStyleVar_ChildBorderSize, // float ChildBorderSize
|
||||
ImGuiStyleVar_PopupRounding, // float PopupRounding
|
||||
@ -799,7 +801,10 @@ enum ImGuiStyleVar_
|
||||
ImGuiStyleVar_ItemSpacing, // ImVec2 ItemSpacing
|
||||
ImGuiStyleVar_ItemInnerSpacing, // ImVec2 ItemInnerSpacing
|
||||
ImGuiStyleVar_IndentSpacing, // float IndentSpacing
|
||||
ImGuiStyleVar_ScrollbarSize, // float ScrollbarSize
|
||||
ImGuiStyleVar_ScrollbarRounding, // float ScrollbarRounding
|
||||
ImGuiStyleVar_GrabMinSize, // float GrabMinSize
|
||||
ImGuiStyleVar_GrabRounding, // float GrabRounding
|
||||
ImGuiStyleVar_ButtonTextAlign, // ImVec2 ButtonTextAlign
|
||||
ImGuiStyleVar_Count_
|
||||
|
||||
@ -1042,6 +1047,7 @@ namespace ImGui
|
||||
static inline bool IsRootWindowFocused() { return IsWindowFocused(ImGuiFocusedFlags_RootWindow); }
|
||||
static inline bool IsRootWindowOrAnyChildFocused() { return IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows); }
|
||||
static inline void SetNextWindowContentWidth(float w) { SetNextWindowContentSize(ImVec2(w, 0.0f)); }
|
||||
static inline float GetItemsLineHeightWithSpacing() { return GetFrameHeightWithSpacing(); }
|
||||
// OBSOLETED in 1.52 (between Aug 2017 and Oct 2017)
|
||||
bool Begin(const char* name, bool* p_open, const ImVec2& size_on_first_use, float bg_alpha_override = -1.0f, ImGuiWindowFlags flags = 0); // Use SetNextWindowSize() instead if you want to set a window size.
|
||||
static inline bool IsRootWindowOrAnyChildHovered() { return IsItemHovered(ImGuiHoveredFlags_RootAndChildWindows); }
|
||||
@ -1464,6 +1470,7 @@ struct ImDrawList
|
||||
int _ChannelsCount; // [Internal] number of active channels (1+)
|
||||
ImVector<ImDrawChannel> _Channels; // [Internal] draw channels for columns API (not resized down so _ChannelsCount may be smaller than _Channels.Size)
|
||||
|
||||
// If you want to create ImDrawList instances, pass them ImGui::GetDrawListSharedData() or create and use your own ImDrawListSharedData (so you can use ImDrawList without ImGui)
|
||||
ImDrawList(const ImDrawListSharedData* shared_data) { _Data = shared_data; _OwnerName = NULL; Clear(); }
|
||||
~ImDrawList() { ClearFreeMemory(); }
|
||||
IMGUI_API void PushClipRect(ImVec2 clip_rect_min, ImVec2 clip_rect_max, bool intersect_with_current_clip_rect = false); // Render-level scissoring. This is passed down to your render function but not used for CPU-side coarse clipping. Prefer using higher-level ImGui::PushClipRect() to affect logic (hit-testing and widget culling)
|
||||
|
@ -2419,7 +2419,7 @@ static void ShowExampleAppFixedOverlay(bool* p_open)
|
||||
ImVec2 window_pos = ImVec2((corner & 1) ? ImGui::GetIO().DisplaySize.x - DISTANCE : DISTANCE, (corner & 2) ? ImGui::GetIO().DisplaySize.y - DISTANCE : DISTANCE);
|
||||
ImVec2 window_pos_pivot = ImVec2((corner & 1) ? 1.0f : 0.0f, (corner & 2) ? 1.0f : 0.0f);
|
||||
ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot);
|
||||
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.0f, 0.0f, 0.0f, 0.3f)); // Transparent background
|
||||
ImGui::SetNextWindowBgAlpha(0.3f); // Transparent background
|
||||
if (ImGui::Begin("Example: Fixed Overlay", p_open, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_NoFocusOnAppearing|ImGuiWindowFlags_NoNavFocus|ImGuiWindowFlags_NoNavInputs))
|
||||
{
|
||||
ImGui::Text("Simple overlay\nin the corner of the screen.\n(right-click to change position)");
|
||||
@ -2436,7 +2436,6 @@ static void ShowExampleAppFixedOverlay(bool* p_open)
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
|
||||
// Demonstrate using "##" and "###" in identifiers to manipulate ID generation.
|
||||
|
@ -485,6 +485,7 @@ struct ImGuiNextWindowData
|
||||
ImGuiCond CollapsedCond;
|
||||
ImGuiCond SizeConstraintCond;
|
||||
ImGuiCond FocusCond;
|
||||
ImGuiCond BgAlphaCond;
|
||||
ImVec2 PosVal;
|
||||
ImVec2 PosPivotVal;
|
||||
ImVec2 SizeVal;
|
||||
@ -493,21 +494,23 @@ struct ImGuiNextWindowData
|
||||
ImRect SizeConstraintRect; // Valid if 'SetNextWindowSizeConstraint' is true
|
||||
ImGuiSizeCallback SizeCallback;
|
||||
void* SizeCallbackUserData;
|
||||
float BgAlphaVal;
|
||||
|
||||
ImGuiNextWindowData()
|
||||
{
|
||||
PosCond = SizeCond = ContentSizeCond = CollapsedCond = SizeConstraintCond = FocusCond = 0;
|
||||
PosCond = SizeCond = ContentSizeCond = CollapsedCond = SizeConstraintCond = FocusCond = BgAlphaCond = 0;
|
||||
PosVal = PosPivotVal = SizeVal = ImVec2(0.0f, 0.0f);
|
||||
ContentSizeVal = ImVec2(0.0f, 0.0f);
|
||||
CollapsedVal = false;
|
||||
SizeConstraintRect = ImRect();
|
||||
SizeCallback = NULL;
|
||||
SizeCallbackUserData = NULL;
|
||||
BgAlphaVal = FLT_MAX;
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
PosCond = SizeCond = ContentSizeCond = CollapsedCond = SizeConstraintCond = FocusCond = 0;
|
||||
PosCond = SizeCond = ContentSizeCond = CollapsedCond = SizeConstraintCond = FocusCond = BgAlphaCond = 0;
|
||||
}
|
||||
};
|
||||
|
||||
@ -549,7 +552,6 @@ struct ImGuiContext
|
||||
ImGuiWindow* ActiveIdWindow;
|
||||
ImGuiInputSource ActiveIdSource; // Activating with mouse or nav (gamepad/keyboard)
|
||||
ImGuiWindow* MovingWindow; // Track the window we clicked on (in order to preserve focus). The actually window that is moved is generally MovingWindow->RootWindow.
|
||||
ImGuiID MovingWindowMoveId; // == MovingWindow->MoveId
|
||||
ImVector<ImGuiColMod> ColorModifiers; // Stack for PushStyleColor()/PopStyleColor()
|
||||
ImVector<ImGuiStyleMod> StyleModifiers; // Stack for PushStyleVar()/PopStyleVar()
|
||||
ImVector<ImFont*> FontStack; // Stack for PushFont()/PopFont()
|
||||
@ -681,7 +683,6 @@ struct ImGuiContext
|
||||
ActiveIdWindow = NULL;
|
||||
ActiveIdSource = ImGuiInputSource_None;
|
||||
MovingWindow = NULL;
|
||||
MovingWindowMoveId = 0;
|
||||
NextTreeNodeOpenVal = false;
|
||||
NextTreeNodeOpenCond = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user