Updated ImGui.
This commit is contained in:
parent
9cc3997795
commit
ef56d9b9b2
37
3rdparty/ocornut-imgui/imgui.cpp
vendored
37
3rdparty/ocornut-imgui/imgui.cpp
vendored
@ -153,6 +153,14 @@
|
||||
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.
|
||||
|
||||
- 2016/05/12 (1.49) - title bar (using TitleBg/TitleBgActive colors) isn't rendered over a window background (WindowBg color) anymore.
|
||||
If your TitleBg/TitleBgActive alpha was 1.0f or you are using the default theme it will not affect you. However if your TitleBg/TitleBgActive alpha was <1.0f you need to tweak your custom theme to readjust for the fact that we don't draw a WindowBg background behind the title bar.
|
||||
This helper function will convert an old TitleBg/TitleBgActive color into a new one with the same visual output, given that color and the WindowBg color.
|
||||
ImVec4 ConvertTitleBgCol(const ImVec4& win_bg_col, const ImVec4& title_bg_col)
|
||||
{
|
||||
float new_a = 1.0f - ((1.0f - win_bg_col.w) * (1.0f - title_bg_col.w)), k = title_bg_col.w / new_a;
|
||||
return ImVec4((win_bg_col.x * win_bg_col.w + title_bg_col.x) * k, (win_bg_col.y * win_bg_col.w + title_bg_col.y) * k, (win_bg_col.z * win_bg_col.w + title_bg_col.z) * k, new_a);
|
||||
}
|
||||
- 2016/05/07 (1.49) - removed confusing set of GetInternalState(), GetInternalStateSize(), SetInternalState() functions. Now using CreateContext(), DestroyContext(), GetCurrentContext(), SetCurrentContext().
|
||||
- 2016/05/02 (1.49) - renamed SetNextTreeNodeOpened() to SetNextTreeNodeOpen(), no redirection.
|
||||
- 2016/05/01 (1.49) - obsoleted old signature of CollapsingHeader(const char* label, const char* str_id = NULL, bool display_frame = true, bool default_open = false) as extra parameters were badly designed and rarely used. You can replace the "default_open = true" flag in new API with CollapsingHeader(label, ImGuiTreeNodeFlags_DefaultOpen).
|
||||
@ -556,6 +564,9 @@
|
||||
- style: WindowPadding needs to be EVEN needs the 0.5 multiplier probably have a subtle effect on clip rectangle
|
||||
- text: simple markup language for color change?
|
||||
- font: dynamic font atlas to avoid baking huge ranges into bitmap and make scaling easier.
|
||||
- font: small opt: for monospace font (like the defalt one) we can trim IndexXAdvance as long as trailing value is == FallbackXAdvance
|
||||
- font: add support for kerning, probably optional. perhaps default to (32..128)^2 matrix ~ 36KB then hash fallback.
|
||||
- font: add a simpler CalcTextSizeA() api? current one ok but not welcome if user needs to call it directly (without going through ImGui::CalcTextSize)
|
||||
- font: fix AddRemapChar() to work before font has been built.
|
||||
- log: LogButtons() options for specifying depth and/or hiding depth slider
|
||||
- log: have more control over the log scope (e.g. stop logging when leaving current tree node scope)
|
||||
@ -747,9 +758,9 @@ ImGuiStyle::ImGuiStyle()
|
||||
Colors[ImGuiCol_FrameBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.30f); // Background of checkbox, radio button, plot, slider, text input
|
||||
Colors[ImGuiCol_FrameBgHovered] = ImVec4(0.90f, 0.80f, 0.80f, 0.40f);
|
||||
Colors[ImGuiCol_FrameBgActive] = ImVec4(0.90f, 0.65f, 0.65f, 0.45f);
|
||||
Colors[ImGuiCol_TitleBg] = ImVec4(0.50f, 0.50f, 1.00f, 0.45f);
|
||||
Colors[ImGuiCol_TitleBg] = ImVec4(0.27f, 0.27f, 0.54f, 0.83f);
|
||||
Colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.40f, 0.40f, 0.80f, 0.20f);
|
||||
Colors[ImGuiCol_TitleBgActive] = ImVec4(0.50f, 0.50f, 1.00f, 0.55f);
|
||||
Colors[ImGuiCol_TitleBgActive] = ImVec4(0.32f, 0.32f, 0.63f, 0.87f);
|
||||
Colors[ImGuiCol_MenuBarBg] = ImVec4(0.40f, 0.40f, 0.55f, 0.80f);
|
||||
Colors[ImGuiCol_ScrollbarBg] = ImVec4(0.20f, 0.25f, 0.30f, 0.60f);
|
||||
Colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.40f, 0.40f, 0.80f, 0.30f);
|
||||
@ -4057,7 +4068,7 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
|
||||
bg_color.w = bg_alpha;
|
||||
bg_color.w *= style.Alpha;
|
||||
if (bg_color.w > 0.0f)
|
||||
window->DrawList->AddRectFilled(window->Pos, window->Pos+window->Size, ColorConvertFloat4ToU32(bg_color), window_rounding);
|
||||
window->DrawList->AddRectFilled(window->Pos+ImVec2(0,window->TitleBarHeight()), window->Pos+window->Size, ColorConvertFloat4ToU32(bg_color), window_rounding, (flags & ImGuiWindowFlags_NoTitleBar) ? 15 : 4|8);
|
||||
|
||||
// Title bar
|
||||
if (!(flags & ImGuiWindowFlags_NoTitleBar))
|
||||
@ -5335,7 +5346,12 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
||||
SetHoveredID(id);
|
||||
if (!(flags & ImGuiButtonFlags_NoKeyModifiers) || (!g.IO.KeyCtrl && !g.IO.KeyShift && !g.IO.KeyAlt))
|
||||
{
|
||||
if ((flags & ImGuiButtonFlags_PressedOnClickRelease) && g.IO.MouseClicked[0]) // Most common type
|
||||
// | CLICKING | HOLDING with ImGuiButtonFlags_Repeat
|
||||
// PressedOnClickRelease | <on release>* | <on repeat> <on repeat> .. (NOT on release) <-- MOST COMMON! (*) only if both click/release were over bounds
|
||||
// PressedOnClick | <on click> | <on click> <on repeat> <on repeat> ..
|
||||
// PressedOnRelease | <on release> | <on repeat> <on repeat> .. (NOT on release)
|
||||
// PressedOnDoubleClick | <on dclick> | <on dclick> <on repeat> <on repeat> ..
|
||||
if ((flags & ImGuiButtonFlags_PressedOnClickRelease) && g.IO.MouseClicked[0])
|
||||
{
|
||||
SetActiveID(id, window); // Hold on ID
|
||||
FocusWindow(window);
|
||||
@ -5348,10 +5364,14 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
||||
}
|
||||
if ((flags & ImGuiButtonFlags_PressedOnRelease) && g.IO.MouseReleased[0])
|
||||
{
|
||||
pressed = true;
|
||||
if (!((flags & ImGuiButtonFlags_Repeat) && g.IO.MouseDownDurationPrev[0] >= g.IO.KeyRepeatDelay)) // Repeat mode trumps <on release>
|
||||
pressed = true;
|
||||
SetActiveID(0);
|
||||
}
|
||||
if ((flags & ImGuiButtonFlags_Repeat) && g.ActiveId == id && ImGui::IsMouseClicked(0, true))
|
||||
|
||||
// 'Repeat' mode acts when held regardless of _PressedOn flags (see table above).
|
||||
// Relies on repeat logic of IsMouseClicked() but we may as well do it ourselves if we end up exposing finer RepeatDelay/RepeatRate settings.
|
||||
if ((flags & ImGuiButtonFlags_Repeat) && g.ActiveId == id && g.IO.MouseDownDuration[0] > 0.0f && ImGui::IsMouseClicked(0, true))
|
||||
pressed = true;
|
||||
}
|
||||
}
|
||||
@ -5366,7 +5386,8 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
||||
else
|
||||
{
|
||||
if (hovered && (flags & ImGuiButtonFlags_PressedOnClickRelease))
|
||||
pressed = true;
|
||||
if (!((flags & ImGuiButtonFlags_Repeat) && g.IO.MouseDownDurationPrev[0] >= g.IO.KeyRepeatDelay)) // Repeat mode trumps <on release>
|
||||
pressed = true;
|
||||
SetActiveID(0);
|
||||
}
|
||||
}
|
||||
@ -9181,7 +9202,7 @@ void ImGui::Columns(int columns_count, const char* id, bool border)
|
||||
continue;
|
||||
|
||||
bool hovered, held;
|
||||
ButtonBehavior(column_rect, column_id, &hovered, &held, true);
|
||||
ButtonBehavior(column_rect, column_id, &hovered, &held);
|
||||
if (hovered || held)
|
||||
g.MouseCursor = ImGuiMouseCursor_ResizeEW;
|
||||
|
||||
|
7
3rdparty/ocornut-imgui/imgui.h
vendored
7
3rdparty/ocornut-imgui/imgui.h
vendored
@ -110,7 +110,7 @@ namespace ImGui
|
||||
IMGUI_API void Render(); // ends the ImGui frame, finalize rendering data, then call your io.RenderDrawListsFn() function if set.
|
||||
IMGUI_API void Shutdown();
|
||||
IMGUI_API void ShowUserGuide(); // help block
|
||||
IMGUI_API void ShowStyleEditor(ImGuiStyle* ref = NULL); // style editor block
|
||||
IMGUI_API void ShowStyleEditor(ImGuiStyle* ref = NULL); // style editor block. you can pass in a reference ImGuiStyle structure to compare to, revert to and save to (else it uses the default style)
|
||||
IMGUI_API void ShowTestWindow(bool* p_open = NULL); // test window demonstrating ImGui features
|
||||
IMGUI_API void ShowMetricsWindow(bool* p_open = NULL); // metrics window for debugging ImGui
|
||||
|
||||
@ -734,7 +734,7 @@ struct ImGuiIO
|
||||
float MouseDoubleClickMaxDist; // = 6.0f // Distance threshold to stay in to validate a double-click, in pixels.
|
||||
float MouseDragThreshold; // = 6.0f // Distance threshold before considering we are dragging
|
||||
int KeyMap[ImGuiKey_COUNT]; // <unset> // Map of indices into the KeysDown[512] entries array
|
||||
float KeyRepeatDelay; // = 0.250f // When holding a key/button, time before it starts repeating, in seconds. (for actions where 'repeat' is active)
|
||||
float KeyRepeatDelay; // = 0.250f // When holding a key/button, time before it starts repeating, in seconds (for buttons in Repeat mode, etc.).
|
||||
float KeyRepeatRate; // = 0.020f // When holding a key/button, rate at which it repeats, in seconds.
|
||||
void* UserData; // = NULL // Store your own data for retrieval by callbacks.
|
||||
|
||||
@ -1257,7 +1257,7 @@ struct ImFontConfig
|
||||
int OversampleH, OversampleV; // 3, 1 // Rasterize at higher quality for sub-pixel positioning. We don't use sub-pixel positions on the Y axis.
|
||||
bool PixelSnapH; // false // Align every character to pixel boundary (if enabled, set OversampleH/V to 1)
|
||||
ImVec2 GlyphExtraSpacing; // 0, 0 // Extra spacing (in pixels) between glyphs
|
||||
const ImWchar* GlyphRanges; // // List of Unicode range (2 value per range, values are inclusive, zero-terminated list)
|
||||
const ImWchar* GlyphRanges; // // Pointer to a user-provided list of Unicode range (2 value per range, values are inclusive, zero-terminated list). THE ARRAY DATA NEEDS TO PERSIST AS LONG AS THE FONT IS ALIVE.
|
||||
bool MergeMode; // false // Merge into previous ImFont, so you can combine multiple inputs font into one ImFont (e.g. ASCII font + icons + Japanese glyphs).
|
||||
bool MergeGlyphCenterV; // false // When merging (multiple ImFontInput for one ImFont), vertically center new glyphs instead of aligning their baseline
|
||||
|
||||
@ -1276,6 +1276,7 @@ struct ImFontConfig
|
||||
// 3. Upload the pixels data into a texture within your graphics system.
|
||||
// 4. Call SetTexID(my_tex_id); and pass the pointer/identifier to your texture. This value will be passed back to you during rendering to identify the texture.
|
||||
// 5. Call ClearTexData() to free textures memory on the heap.
|
||||
// NB: If you use a 'glyph_ranges' array you need to make sure that your array persist up until the ImFont is cleared. We only copy the pointer, not the data.
|
||||
struct ImFontAtlas
|
||||
{
|
||||
IMGUI_API ImFontAtlas();
|
||||
|
18
3rdparty/ocornut-imgui/imgui_demo.cpp
vendored
18
3rdparty/ocornut-imgui/imgui_demo.cpp
vendored
@ -1218,7 +1218,7 @@ void ImGui::ShowTestWindow(bool* p_open)
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
static ImVec4 color = ImColor(1.0f, 0.0f, 1.0f, 1.0f);
|
||||
static ImVec4 color = ImColor(0.8f, 0.5f, 1.0f, 1.0f);
|
||||
ImGui::ColorButton(color);
|
||||
if (ImGui::BeginPopupContextItem("color context menu"))
|
||||
{
|
||||
@ -1554,9 +1554,11 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
||||
{
|
||||
ImGuiStyle& style = ImGui::GetStyle();
|
||||
|
||||
const ImGuiStyle def; // Default style
|
||||
// You can pass in a reference ImGuiStyle structure to compare to, revert to and save to (else it compares to the default style)
|
||||
const ImGuiStyle default_style; // Default style
|
||||
if (ImGui::Button("Revert Style"))
|
||||
style = ref ? *ref : def;
|
||||
style = ref ? *ref : default_style;
|
||||
|
||||
if (ref)
|
||||
{
|
||||
ImGui::SameLine();
|
||||
@ -1611,7 +1613,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
||||
{
|
||||
const ImVec4& col = style.Colors[i];
|
||||
const char* name = ImGui::GetStyleColName(i);
|
||||
if (!output_only_modified || memcmp(&col, (ref ? &ref->Colors[i] : &def.Colors[i]), sizeof(ImVec4)) != 0)
|
||||
if (!output_only_modified || memcmp(&col, (ref ? &ref->Colors[i] : &default_style.Colors[i]), sizeof(ImVec4)) != 0)
|
||||
ImGui::LogText("style.Colors[ImGuiCol_%s]%*s= ImVec4(%.2ff, %.2ff, %.2ff, %.2ff);" IM_NEWLINE, name, 22 - (int)strlen(name), "", col.x, col.y, col.z, col.w);
|
||||
}
|
||||
ImGui::LogFinish();
|
||||
@ -1640,9 +1642,9 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
||||
continue;
|
||||
ImGui::PushID(i);
|
||||
ImGui::ColorEdit4(name, (float*)&style.Colors[i], true);
|
||||
if (memcmp(&style.Colors[i], (ref ? &ref->Colors[i] : &def.Colors[i]), sizeof(ImVec4)) != 0)
|
||||
if (memcmp(&style.Colors[i], (ref ? &ref->Colors[i] : &default_style.Colors[i]), sizeof(ImVec4)) != 0)
|
||||
{
|
||||
ImGui::SameLine(); if (ImGui::Button("Revert")) style.Colors[i] = ref ? ref->Colors[i] : def.Colors[i];
|
||||
ImGui::SameLine(); if (ImGui::Button("Revert")) style.Colors[i] = ref ? ref->Colors[i] : default_style.Colors[i];
|
||||
if (ref) { ImGui::SameLine(); if (ImGui::Button("Save")) ref->Colors[i] = style.Colors[i]; }
|
||||
}
|
||||
ImGui::PopID();
|
||||
@ -2461,7 +2463,7 @@ static void ShowExampleAppLongText(bool* p_open)
|
||||
#else
|
||||
|
||||
void ImGui::ShowTestWindow(bool*) {}
|
||||
void ImGui::ShowUserGuide(bool*) {}
|
||||
void ImGui::ShowStyleEditor(bool*) {}
|
||||
void ImGui::ShowUserGuide() {}
|
||||
void ImGui::ShowStyleEditor(ImGuiStyle*) {}
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user