mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 00:58:30 -05:00
Updated ImGui.
This commit is contained in:
parent
1611b074fb
commit
50bb6f6506
5 changed files with 52 additions and 37 deletions
3
3rdparty/ocornut-imgui/imconfig.h
vendored
3
3rdparty/ocornut-imgui/imconfig.h
vendored
|
@ -12,7 +12,8 @@
|
|||
//#define ImVector MyVector
|
||||
|
||||
//---- Define assertion handler. Defaults to calling assert().
|
||||
//#define IM_ASSERT(_EXPR) MyAssert(_EXPR)
|
||||
#include <assert.h>
|
||||
#define IM_ASSERT(_EXPR, ...) assert(_EXPR)
|
||||
|
||||
//---- Define attributes of all API symbols declarations, e.g. for DLL under Windows.
|
||||
//#define IMGUI_API __declspec( dllexport )
|
||||
|
|
49
3rdparty/ocornut-imgui/imgui.cpp
vendored
49
3rdparty/ocornut-imgui/imgui.cpp
vendored
|
@ -1572,11 +1572,18 @@ void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window = NULL)
|
|||
{
|
||||
ImGuiState& g = *GImGui;
|
||||
g.ActiveId = id;
|
||||
g.ActiveIdIsFocusedOnly = false;
|
||||
g.ActiveIdAllowHoveringOthers = false;
|
||||
g.ActiveIdIsJustActivated = true;
|
||||
g.ActiveIdWindow = window;
|
||||
}
|
||||
|
||||
void ImGui::SetHoveredID(ImGuiID id)
|
||||
{
|
||||
ImGuiState& g = *GImGui;
|
||||
g.HoveredId = id;
|
||||
g.HoveredIdAllowHoveringOthers = false;
|
||||
}
|
||||
|
||||
void ImGui::KeepAliveID(ImGuiID id)
|
||||
{
|
||||
ImGuiState& g = *GImGui;
|
||||
|
@ -1635,7 +1642,7 @@ bool ImGui::ItemAdd(const ImRect& bb, const ImGuiID* id)
|
|||
window->DC.LastItemHoveredRect = true;
|
||||
window->DC.LastItemHoveredAndUsable = false;
|
||||
if (g.HoveredRootWindow == window->RootWindow)
|
||||
if (g.ActiveId == 0 || (id && g.ActiveId == *id) || g.ActiveIdIsFocusedOnly || (g.ActiveId == window->MoveID))
|
||||
if (g.ActiveId == 0 || (id && g.ActiveId == *id) || g.ActiveIdAllowHoveringOthers || (g.ActiveId == window->MoveID))
|
||||
if (IsWindowContentHoverable(window))
|
||||
window->DC.LastItemHoveredAndUsable = true;
|
||||
}
|
||||
|
@ -1664,11 +1671,11 @@ bool ImGui::IsClippedEx(const ImRect& bb, const ImGuiID* id, bool clip_even_when
|
|||
bool ImGui::IsHovered(const ImRect& bb, ImGuiID id, bool flatten_childs)
|
||||
{
|
||||
ImGuiState& g = *GImGui;
|
||||
if (g.HoveredId == 0 || g.HoveredId == id)
|
||||
if (g.HoveredId == 0 || g.HoveredId == id || g.HoveredIdAllowHoveringOthers)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindowRead();
|
||||
if (g.HoveredWindow == window || (flatten_childs && g.HoveredRootWindow == window->RootWindow))
|
||||
if ((g.ActiveId == 0 || g.ActiveId == id || g.ActiveIdIsFocusedOnly) && ImGui::IsMouseHoveringRect(bb.Min, bb.Max))
|
||||
if ((g.ActiveId == 0 || g.ActiveId == id || g.ActiveIdAllowHoveringOthers) && ImGui::IsMouseHoveringRect(bb.Min, bb.Max))
|
||||
if (IsWindowContentHoverable(g.HoveredRootWindow))
|
||||
return true;
|
||||
}
|
||||
|
@ -1885,6 +1892,7 @@ void ImGui::NewFrame()
|
|||
// Clear reference to active widget if the widget isn't alive anymore
|
||||
g.HoveredIdPreviousFrame = g.HoveredId;
|
||||
g.HoveredId = 0;
|
||||
g.HoveredIdAllowHoveringOthers = false;
|
||||
if (!g.ActiveIdIsAlive && g.ActiveIdPreviousFrame == g.ActiveId && g.ActiveId != 0)
|
||||
SetActiveID(0);
|
||||
g.ActiveIdPreviousFrame = g.ActiveId;
|
||||
|
@ -3290,13 +3298,13 @@ void ImGui::EndChild()
|
|||
}
|
||||
|
||||
// Helper to create a child window / scrolling region that looks like a normal widget frame.
|
||||
bool ImGui::BeginChildFrame(ImGuiID id, const ImVec2& size)
|
||||
bool ImGui::BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags extra_flags)
|
||||
{
|
||||
ImGuiState& g = *GImGui;
|
||||
const ImGuiStyle& style = g.Style;
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildWindowBg, style.Colors[ImGuiCol_FrameBg]);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ChildWindowRounding, style.FrameRounding);
|
||||
return ImGui::BeginChild(id, size, false, ImGuiWindowFlags_NoMove);
|
||||
return ImGui::BeginChild(id, size, false, ImGuiWindowFlags_NoMove | extra_flags);
|
||||
}
|
||||
|
||||
void ImGui::EndChildFrame()
|
||||
|
@ -4085,7 +4093,7 @@ static void Scrollbar(ImGuiWindow* window, bool horizontal)
|
|||
|
||||
// Click position in scrollbar normalized space (0.0f->1.0f)
|
||||
const float clicked_v_norm = ImSaturate((mouse_pos_v - scrollbar_pos_v) / scrollbar_size_v);
|
||||
g.HoveredId = id;
|
||||
ImGui::SetHoveredID(id);
|
||||
|
||||
bool seek_absolute = false;
|
||||
if (!previously_held)
|
||||
|
@ -5107,7 +5115,7 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
|||
const bool hovered = IsHovered(bb, id, (flags & ImGuiButtonFlags_FlattenChilds) != 0);
|
||||
if (hovered)
|
||||
{
|
||||
g.HoveredId = id;
|
||||
SetHoveredID(id);
|
||||
if (allow_key_modifiers || (!g.IO.KeyCtrl && !g.IO.KeyShift && !g.IO.KeyAlt))
|
||||
{
|
||||
if (g.IO.MouseClicked[0])
|
||||
|
@ -5846,7 +5854,7 @@ bool ImGui::InputScalarAsWidgetReplacement(const ImRect& aabb, const char* label
|
|||
|
||||
// Our replacement widget will override the focus ID (registered previously to allow for a TAB focus to happen)
|
||||
SetActiveID(g.ScalarAsInputTextId, window);
|
||||
g.HoveredId = 0;
|
||||
SetHoveredID(0);
|
||||
FocusableItemUnregister(window);
|
||||
|
||||
char buf[32];
|
||||
|
@ -5857,7 +5865,7 @@ bool ImGui::InputScalarAsWidgetReplacement(const ImRect& aabb, const char* label
|
|||
// First frame
|
||||
IM_ASSERT(g.ActiveId == id); // InputText ID expected to match the Slider ID (else we'd need to store them both, which is also possible)
|
||||
g.ScalarAsInputTextId = g.ActiveId;
|
||||
g.HoveredId = id;
|
||||
SetHoveredID(id);
|
||||
}
|
||||
else if (g.ActiveId != g.ScalarAsInputTextId)
|
||||
{
|
||||
|
@ -6063,7 +6071,7 @@ bool ImGui::SliderFloat(const char* label, float* v, float v_min, float v_max, c
|
|||
|
||||
const bool hovered = IsHovered(frame_bb, id);
|
||||
if (hovered)
|
||||
g.HoveredId = id;
|
||||
SetHoveredID(id);
|
||||
|
||||
if (!display_format)
|
||||
display_format = "%.3f";
|
||||
|
@ -6122,7 +6130,7 @@ bool ImGui::VSliderFloat(const char* label, const ImVec2& size, float* v, float
|
|||
|
||||
const bool hovered = IsHovered(frame_bb, id);
|
||||
if (hovered)
|
||||
g.HoveredId = id;
|
||||
SetHoveredID(id);
|
||||
|
||||
if (!display_format)
|
||||
display_format = "%.3f";
|
||||
|
@ -6363,7 +6371,7 @@ bool ImGui::DragFloat(const char* label, float* v, float v_speed, float v_min, f
|
|||
|
||||
const bool hovered = IsHovered(frame_bb, id);
|
||||
if (hovered)
|
||||
g.HoveredId = id;
|
||||
SetHoveredID(id);
|
||||
|
||||
if (!display_format)
|
||||
display_format = "%.3f";
|
||||
|
@ -7108,7 +7116,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
|||
const bool hovered = IsHovered(frame_bb, id);
|
||||
if (hovered)
|
||||
{
|
||||
g.HoveredId = id;
|
||||
SetHoveredID(id);
|
||||
g.MouseCursor = ImGuiMouseCursor_TextInput;
|
||||
}
|
||||
const bool user_clicked = hovered && io.MouseClicked[0];
|
||||
|
@ -7123,8 +7131,8 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
|||
// Take a copy of the initial buffer value (both in original UTF-8 format and converted to wchar)
|
||||
// From the moment we focused we are ignoring the content of 'buf'
|
||||
const int prev_len_w = edit_state.CurLenW;
|
||||
edit_state.Text.resize(buf_size); // wchar count <= utf-8 count
|
||||
edit_state.InitialText.resize(buf_size); // utf-8
|
||||
edit_state.Text.resize(buf_size+1); // wchar count <= utf-8 count. we use +1 to make sure that .Data isn't NULL so it doesn't crash.
|
||||
edit_state.InitialText.resize(buf_size+1); // utf-8. we use +1 to make sure that .Data isn't NULL so it doesn't crash.
|
||||
ImFormatString(edit_state.InitialText.Data, edit_state.InitialText.Size, "%s", buf);
|
||||
const char* buf_end = NULL;
|
||||
edit_state.CurLenW = ImTextStrFromUtf8(edit_state.Text.Data, edit_state.Text.Size, buf, NULL, &buf_end);
|
||||
|
@ -7176,7 +7184,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
|||
|
||||
// Although we are active we don't prevent mouse from hovering other elements unless we are interacting right now with the widget.
|
||||
// Down the line we should have a cleaner concept of focused vs active in the library.
|
||||
g.ActiveIdIsFocusedOnly = !io.MouseDown[0];
|
||||
g.ActiveIdAllowHoveringOthers = !io.MouseDown[0];
|
||||
|
||||
// Edit in progress
|
||||
const float mouse_x = (g.IO.MousePos.x - frame_bb.Min.x - style.FramePadding.x) + edit_state.ScrollX;
|
||||
|
@ -7835,7 +7843,7 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
|
|||
bool menu_toggled = false;
|
||||
if (hovered)
|
||||
{
|
||||
g.HoveredId = id;
|
||||
SetHoveredID(id);
|
||||
if (g.IO.MouseClicked[0])
|
||||
{
|
||||
SetActiveID(0);
|
||||
|
@ -8520,7 +8528,10 @@ void ImGui::Dummy(const ImVec2& size)
|
|||
ImGuiWindow* window = GetCurrentWindow();
|
||||
if (window->SkipItems)
|
||||
return;
|
||||
ItemSize(size);
|
||||
|
||||
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
|
||||
ItemSize(bb);
|
||||
ItemAdd(bb, NULL);
|
||||
}
|
||||
|
||||
bool ImGui::IsRectVisible(const ImVec2& size)
|
||||
|
|
5
3rdparty/ocornut-imgui/imgui.h
vendored
5
3rdparty/ocornut-imgui/imgui.h
vendored
|
@ -22,7 +22,7 @@
|
|||
// Define assertion handler.
|
||||
#ifndef IM_ASSERT
|
||||
#include <assert.h>
|
||||
#define IM_ASSERT(_EXPR, ...) assert(_EXPR)
|
||||
#define IM_ASSERT(_EXPR) assert(_EXPR)
|
||||
#endif
|
||||
|
||||
// Define attributes of all API symbols declarations, e.g. for DLL under Windows.
|
||||
|
@ -386,7 +386,7 @@ namespace ImGui
|
|||
IMGUI_API ImVec2 CalcTextSize(const char* text, const char* text_end = NULL, bool hide_text_after_double_hash = false, float wrap_width = -1.0f);
|
||||
IMGUI_API void CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end); // calculate coarse clipping for large list of evenly sized items. Prefer using the ImGuiListClipper higher-level helper if you can.
|
||||
|
||||
IMGUI_API bool BeginChildFrame(ImGuiID id, const ImVec2& size); // helper to create a child window / scrolling region that looks like a normal widget frame
|
||||
IMGUI_API bool BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags extra_flags = 0); // helper to create a child window / scrolling region that looks like a normal widget frame
|
||||
IMGUI_API void EndChildFrame();
|
||||
|
||||
IMGUI_API ImVec4 ColorConvertU32ToFloat4(ImU32 in);
|
||||
|
@ -887,6 +887,7 @@ struct ImGuiTextBuffer
|
|||
int size() const { return Buf.Size - 1; }
|
||||
bool empty() { return Buf.Size >= 2; }
|
||||
void clear() { Buf.clear(); Buf.push_back(0); }
|
||||
const char* c_str() const { return Buf.Data; }
|
||||
IMGUI_API void append(const char* fmt, ...) IM_PRINTFARGS(2);
|
||||
IMGUI_API void appendv(const char* fmt, va_list args);
|
||||
};
|
||||
|
|
7
3rdparty/ocornut-imgui/imgui_demo.cpp
vendored
7
3rdparty/ocornut-imgui/imgui_demo.cpp
vendored
|
@ -13,7 +13,6 @@
|
|||
#include <ctype.h> // toupper, isprint
|
||||
#include <math.h> // sqrtf, fabsf, fmodf, powf, cosf, sinf, floorf, ceilf
|
||||
#include <stdio.h> // vsnprintf, sscanf, printf
|
||||
#include <stdint.h> // intptr_t
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
|
||||
|
@ -217,7 +216,7 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||
{
|
||||
ImFont* font = atlas->Fonts[i];
|
||||
ImGui::BulletText("Font %d: \'%s\', %.2f px, %d glyphs", i, font->ConfigData ? font->ConfigData[0].Name : "", font->FontSize, font->Glyphs.Size);
|
||||
ImGui::TreePush((void*)intptr_t(i));
|
||||
ImGui::TreePush((void*)i);
|
||||
if (i > 0) { ImGui::SameLine(); if (ImGui::SmallButton("Set as default")) { atlas->Fonts[i] = atlas->Fonts[0]; atlas->Fonts[0] = font; } }
|
||||
ImGui::PushFont(font);
|
||||
ImGui::Text("The quick brown fox jumps over the lazy dog");
|
||||
|
@ -255,7 +254,7 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||
{
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
if (ImGui::TreeNode((void*)intptr_t(i), "Child %d", i))
|
||||
if (ImGui::TreeNode((void*)i, "Child %d", i))
|
||||
{
|
||||
ImGui::Text("blah blah");
|
||||
ImGui::SameLine();
|
||||
|
@ -942,7 +941,7 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||
if (i > 0) ImGui::SameLine();
|
||||
ImGui::BeginGroup();
|
||||
ImGui::Text("%s", i == 0 ? "Top" : i == 1 ? "25%" : i == 2 ? "Center" : i == 3 ? "75%" : "Bottom");
|
||||
ImGui::BeginChild(ImGui::GetID((void*)intptr_t(i)), ImVec2(ImGui::GetWindowWidth() * 0.17f, 200.0f), true);
|
||||
ImGui::BeginChild(ImGui::GetID((void*)i), ImVec2(ImGui::GetWindowWidth() * 0.17f, 200.0f), true);
|
||||
if (scroll_to)
|
||||
ImGui::SetScrollFromPosY(ImGui::GetCursorStartPos().y + scroll_to_px, i * 0.25f);
|
||||
for (int line = 0; line < 100; line++)
|
||||
|
|
7
3rdparty/ocornut-imgui/imgui_internal.h
vendored
7
3rdparty/ocornut-imgui/imgui_internal.h
vendored
|
@ -346,12 +346,13 @@ struct ImGuiState
|
|||
ImGuiWindow* HoveredWindow; // Will catch mouse inputs
|
||||
ImGuiWindow* HoveredRootWindow; // Will catch mouse inputs (for focus/move only)
|
||||
ImGuiID HoveredId; // Hovered widget
|
||||
bool HoveredIdAllowHoveringOthers;
|
||||
ImGuiID HoveredIdPreviousFrame;
|
||||
ImGuiID ActiveId; // Active widget
|
||||
ImGuiID ActiveIdPreviousFrame;
|
||||
bool ActiveIdIsAlive;
|
||||
bool ActiveIdIsJustActivated; // Set at the time of activation for one frame
|
||||
bool ActiveIdIsFocusedOnly; // Set only by active widget. Denote focus but no active interaction
|
||||
bool ActiveIdAllowHoveringOthers; // Set only by active widget
|
||||
ImGuiWindow* ActiveIdWindow;
|
||||
ImGuiWindow* MovedWindow; // Track the child window we clicked on to move a window. Pointer is only valid if ActiveID is the "#MOVE" identifier of a window.
|
||||
ImVector<ImGuiIniData> Settings; // .ini Settings
|
||||
|
@ -428,12 +429,13 @@ struct ImGuiState
|
|||
HoveredWindow = NULL;
|
||||
HoveredRootWindow = NULL;
|
||||
HoveredId = 0;
|
||||
HoveredIdAllowHoveringOthers = false;
|
||||
HoveredIdPreviousFrame = 0;
|
||||
ActiveId = 0;
|
||||
ActiveIdPreviousFrame = 0;
|
||||
ActiveIdIsAlive = false;
|
||||
ActiveIdIsJustActivated = false;
|
||||
ActiveIdIsFocusedOnly = false;
|
||||
ActiveIdAllowHoveringOthers = false;
|
||||
ActiveIdWindow = NULL;
|
||||
MovedWindow = NULL;
|
||||
SettingsDirtyTimer = 0.0f;
|
||||
|
@ -647,6 +649,7 @@ namespace ImGui
|
|||
IMGUI_API void FocusWindow(ImGuiWindow* window);
|
||||
|
||||
IMGUI_API void SetActiveID(ImGuiID id, ImGuiWindow* window);
|
||||
IMGUI_API void SetHoveredID(ImGuiID id);
|
||||
IMGUI_API void KeepAliveID(ImGuiID id);
|
||||
|
||||
IMGUI_API void EndFrame(); // This automatically called by Render()
|
||||
|
|
Loading…
Reference in a new issue