|
@@ -26,11 +26,12 @@
|
|
|
- I integrated ImGui in my engine and the text or lines are blurry..
|
|
- 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..
|
|
- 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 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 load a different font than the default?
|
|
|
- How can I easily use icons in my application?
|
|
- How can I easily use icons in my application?
|
|
|
- How can I load multiple fonts?
|
|
- How can I load multiple fonts?
|
|
|
- How can I display and input non-latin characters such as Chinese, Japanese, Korean, Cyrillic?
|
|
- 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)
|
|
- How can I use the drawing facilities without an ImGui window? (using ImDrawList API)
|
|
|
- ISSUES & TODO-LIST
|
|
- ISSUES & TODO-LIST
|
|
|
- CODE
|
|
- CODE
|
|
@@ -158,7 +159,8 @@
|
|
|
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.
|
|
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.
|
|
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/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 '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))'
|
|
- 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
|
|
- 2017/07/20 (1.51) - removed IsPosHoveringAnyWindow(ImVec2), which was partly broken and misleading. ASSERT + redirect user to io.WantCaptureMouse
|
|
@@ -405,7 +407,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 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!
|
|
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.
|
|
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.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).
|
|
- 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).
|
|
@@ -456,19 +458,33 @@
|
|
|
|
|
|
|
|
Q: How can I display and input non-Latin characters such as Chinese, Japanese, Korean, Cyrillic?
|
|
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.
|
|
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);
|
|
|
|
|
+
|
|
|
|
|
+ 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.
|
|
|
|
|
|
|
|
- As for text input, depends on you passing the right character code to io.AddInputCharacter(). The example applications do that.
|
|
|
|
|
|
|
+ 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)
|
|
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,
|
|
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.
|
|
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: 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"
|
|
- tip: you can create widgets without a Begin()/End() block, they will go in an implicit window called "Debug"
|
|
@@ -745,12 +761,13 @@ static void ImeSetInputScreenPosFn_DefaultImpl(int x, int y);
|
|
|
// Context
|
|
// 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.
|
|
// New contexts always point by default to this font atlas. It can be changed by reassigning the GetIO().Fonts variable.
|
|
|
static ImFontAtlas GImDefaultFontAtlas;
|
|
static ImFontAtlas GImDefaultFontAtlas;
|
|
|
|
|
|
|
|
// Default context storage + current context pointer.
|
|
// 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()
|
|
// 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:
|
|
// 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)
|
|
// - 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
|
|
// - 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
|
|
@@ -3091,20 +3108,13 @@ void ImGui::RenderCheckMark(ImVec2 pos, ImU32 col)
|
|
|
{
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
|
ImGuiWindow* window = GetCurrentWindow();
|
|
ImGuiWindow* window = GetCurrentWindow();
|
|
|
-
|
|
|
|
|
- ImVec2 a, b, c;
|
|
|
|
|
float start_x = (float)(int)(g.FontSize * 0.307f + 0.5f);
|
|
float start_x = (float)(int)(g.FontSize * 0.307f + 0.5f);
|
|
|
float rem_third = (float)(int)((g.FontSize - start_x) / 3.0f);
|
|
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);
|
|
window->DrawList->PathStroke(col, false);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -9512,20 +9522,19 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
|
|
PushID(label);
|
|
PushID(label);
|
|
|
BeginGroup();
|
|
BeginGroup();
|
|
|
|
|
|
|
|
- if ((flags & ImGuiColorEditFlags_NoSidePreview) == 0)
|
|
|
|
|
|
|
+ if (!(flags & ImGuiColorEditFlags_NoSidePreview))
|
|
|
flags |= ImGuiColorEditFlags_NoSmallPreview;
|
|
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);
|
|
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);
|
|
flags |= (g.ColorEditOptions & ImGuiColorEditFlags_AlphaBar);
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
// Setup
|
|
// Setup
|
|
|
bool alpha_bar = (flags & ImGuiColorEditFlags_AlphaBar) && !(flags & ImGuiColorEditFlags_NoAlpha);
|
|
bool alpha_bar = (flags & ImGuiColorEditFlags_AlphaBar) && !(flags & ImGuiColorEditFlags_NoAlpha);
|
|
@@ -9667,7 +9676,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
|
|
if ((flags & ImGuiColorEditFlags_NoInputs) == 0)
|
|
if ((flags & ImGuiColorEditFlags_NoInputs) == 0)
|
|
|
{
|
|
{
|
|
|
PushItemWidth((alpha_bar ? bar1_pos_x : bar0_pos_x) + bars_width - picker_pos.x);
|
|
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;
|
|
ImGuiColorEditFlags sub_flags = (flags & sub_flags_to_forward) | ImGuiColorEditFlags_NoPicker;
|
|
|
if (flags & ImGuiColorEditFlags_RGB || (flags & ImGuiColorEditFlags__InputsMask) == 0)
|
|
if (flags & ImGuiColorEditFlags_RGB || (flags & ImGuiColorEditFlags__InputsMask) == 0)
|
|
|
value_changed |= ColorEdit4("##rgb", col, sub_flags | ImGuiColorEditFlags_RGB);
|
|
value_changed |= ColorEdit4("##rgb", col, sub_flags | ImGuiColorEditFlags_RGB);
|
|
@@ -10241,21 +10250,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
|
|
// PLATFORM DEPENDENT HELPERS
|
|
|
//-----------------------------------------------------------------------------
|
|
//-----------------------------------------------------------------------------
|