|
@@ -1,4 +1,4 @@
|
|
-// dear imgui, v1.62
|
|
|
|
|
|
+// dear imgui, v1.63 WIP
|
|
// (main code and documentation)
|
|
// (main code and documentation)
|
|
|
|
|
|
// Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp for demo code.
|
|
// Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp for demo code.
|
|
@@ -453,7 +453,7 @@
|
|
Note: The 'io.WantCaptureMouse' is more accurate that any attempt to "check if the mouse is hovering a window" (don't do that!).
|
|
Note: The 'io.WantCaptureMouse' is more accurate that any attempt to "check if the mouse is hovering a window" (don't do that!).
|
|
It handle mouse dragging correctly (both dragging that started over your application or over an imgui window) and handle e.g. modal windows blocking inputs.
|
|
It handle mouse dragging correctly (both dragging that started over your application or over an imgui window) and handle e.g. modal windows blocking inputs.
|
|
Those flags are updated by ImGui::NewFrame(). Preferably read the flags after calling NewFrame() if you can afford it, but reading them before is also
|
|
Those flags are updated by ImGui::NewFrame(). Preferably read the flags after calling NewFrame() if you can afford it, but reading them before is also
|
|
- perfectly fine, as the bool toggle fairly rarely. If you have on a touch device, you might find use for an early call to NewFrameUpdateHoveredWindowAndCaptureFlags().
|
|
|
|
|
|
+ perfectly fine, as the bool toggle fairly rarely. If you have on a touch device, you might find use for an early call to UpdateHoveredWindowAndCaptureFlags().
|
|
Note: Text input widget releases focus on "Return KeyDown", so the subsequent "Return KeyUp" event that your application receive will typically
|
|
Note: Text input widget releases focus on "Return KeyDown", so the subsequent "Return KeyUp" event that your application receive will typically
|
|
have 'io.WantCaptureKeyboard=false'. Depending on your application logic it may or not be inconvenient. You might want to track which key-downs
|
|
have 'io.WantCaptureKeyboard=false'. Depending on your application logic it may or not be inconvenient. You might want to track which key-downs
|
|
were targeted for Dear ImGui, e.g. with an array of bool, and filter out the corresponding key-ups.)
|
|
were targeted for Dear ImGui, e.g. with an array of bool, and filter out the corresponding key-ups.)
|
|
@@ -861,7 +861,6 @@ static void NavUpdate();
|
|
static void NavUpdateWindowing();
|
|
static void NavUpdateWindowing();
|
|
static void NavProcessItem(ImGuiWindow* window, const ImRect& nav_bb, const ImGuiID id);
|
|
static void NavProcessItem(ImGuiWindow* window, const ImRect& nav_bb, const ImGuiID id);
|
|
|
|
|
|
-static void UpdateMovingWindow();
|
|
|
|
static void UpdateMouseInputs();
|
|
static void UpdateMouseInputs();
|
|
static void UpdateManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4]);
|
|
static void UpdateManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4]);
|
|
static void FocusFrontMostActiveWindow(ImGuiWindow* ignore_window);
|
|
static void FocusFrontMostActiveWindow(ImGuiWindow* ignore_window);
|
|
@@ -2088,7 +2087,7 @@ ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name)
|
|
CollapseToggleWanted = false;
|
|
CollapseToggleWanted = false;
|
|
SkipItems = false;
|
|
SkipItems = false;
|
|
Appearing = false;
|
|
Appearing = false;
|
|
- CloseButton = false;
|
|
|
|
|
|
+ HasCloseButton = false;
|
|
BeginOrderWithinParent = -1;
|
|
BeginOrderWithinParent = -1;
|
|
BeginOrderWithinContext = -1;
|
|
BeginOrderWithinContext = -1;
|
|
BeginCount = 0;
|
|
BeginCount = 0;
|
|
@@ -3596,7 +3595,7 @@ static void ImGui::UpdateTryMergeWindowIntoHostViewport(ImGuiWindow* window, ImG
|
|
SetWindowViewport(window, viewport);
|
|
SetWindowViewport(window, viewport);
|
|
}
|
|
}
|
|
|
|
|
|
-static void ImGui::UpdateMovingWindow()
|
|
|
|
|
|
+void ImGui::UpdateMovingWindow()
|
|
{
|
|
{
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
if (g.MovingWindow != NULL)
|
|
if (g.MovingWindow != NULL)
|
|
@@ -4035,7 +4034,7 @@ static void ImGui::UpdateMouseInputs()
|
|
}
|
|
}
|
|
|
|
|
|
// The reason this is exposed in imgui_internal.h is: on touch-based system that don't have hovering, we want to dispatch inputs to the right target (imgui vs imgui+app)
|
|
// The reason this is exposed in imgui_internal.h is: on touch-based system that don't have hovering, we want to dispatch inputs to the right target (imgui vs imgui+app)
|
|
-void ImGui::NewFrameUpdateHoveredWindowAndCaptureFlags()
|
|
|
|
|
|
+void ImGui::UpdateHoveredWindowAndCaptureFlags()
|
|
{
|
|
{
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
|
|
|
|
@@ -4244,7 +4243,7 @@ void ImGui::NewFrame()
|
|
|
|
|
|
// Handle user moving window with mouse (at the beginning of the frame to avoid input lag or sheering)
|
|
// Handle user moving window with mouse (at the beginning of the frame to avoid input lag or sheering)
|
|
UpdateMovingWindow();
|
|
UpdateMovingWindow();
|
|
- NewFrameUpdateHoveredWindowAndCaptureFlags();
|
|
|
|
|
|
+ UpdateHoveredWindowAndCaptureFlags();
|
|
|
|
|
|
if (GetFrontMostPopupModal() != NULL)
|
|
if (GetFrontMostPopupModal() != NULL)
|
|
g.ModalWindowDarkeningRatio = ImMin(g.ModalWindowDarkeningRatio + g.IO.DeltaTime * 6.0f, 1.0f);
|
|
g.ModalWindowDarkeningRatio = ImMin(g.ModalWindowDarkeningRatio + g.IO.DeltaTime * 6.0f, 1.0f);
|
|
@@ -6862,7 +6861,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
window_just_activated_by_user |= (window != popup_ref.Window);
|
|
window_just_activated_by_user |= (window != popup_ref.Window);
|
|
}
|
|
}
|
|
window->Appearing = (window_just_activated_by_user || window_just_appearing_after_hidden_for_resize);
|
|
window->Appearing = (window_just_activated_by_user || window_just_appearing_after_hidden_for_resize);
|
|
- window->CloseButton = (p_open != NULL);
|
|
|
|
|
|
+ window->HasCloseButton = (p_open != NULL);
|
|
if (window->Appearing)
|
|
if (window->Appearing)
|
|
SetWindowConditionAllowFlags(window, ImGuiCond_Appearing, true);
|
|
SetWindowConditionAllowFlags(window, ImGuiCond_Appearing, true);
|
|
|
|
|
|
@@ -9026,7 +9025,7 @@ bool ImGui::SmallButton(const char* label)
|
|
return pressed;
|
|
return pressed;
|
|
}
|
|
}
|
|
|
|
|
|
-bool ImGui::ArrowButton(const char* str_id, ImGuiDir dir)
|
|
|
|
|
|
+bool ImGui::ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size, ImGuiButtonFlags flags)
|
|
{
|
|
{
|
|
ImGuiWindow* window = GetCurrentWindow();
|
|
ImGuiWindow* window = GetCurrentWindow();
|
|
if (window->SkipItems)
|
|
if (window->SkipItems)
|
|
@@ -9034,24 +9033,33 @@ bool ImGui::ArrowButton(const char* str_id, ImGuiDir dir)
|
|
|
|
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
const ImGuiID id = window->GetID(str_id);
|
|
const ImGuiID id = window->GetID(str_id);
|
|
- float sz = ImGui::GetFrameHeight();
|
|
|
|
- const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(sz, sz));
|
|
|
|
- ItemSize(bb);
|
|
|
|
|
|
+ const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
|
|
|
|
+ const float default_size = GetFrameHeight();
|
|
|
|
+ ItemSize(bb, (size.y >= default_size) ? g.Style.FramePadding.y : 0.0f);
|
|
if (!ItemAdd(bb, id))
|
|
if (!ItemAdd(bb, id))
|
|
return false;
|
|
return false;
|
|
|
|
|
|
|
|
+ if (window->DC.ItemFlags & ImGuiItemFlags_ButtonRepeat)
|
|
|
|
+ flags |= ImGuiButtonFlags_Repeat;
|
|
|
|
+
|
|
bool hovered, held;
|
|
bool hovered, held;
|
|
- bool pressed = ButtonBehavior(bb, id, &hovered, &held);
|
|
|
|
|
|
+ bool pressed = ButtonBehavior(bb, id, &hovered, &held, flags);
|
|
|
|
|
|
// Render
|
|
// Render
|
|
const ImU32 col = GetColorU32((hovered && held) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
|
|
const ImU32 col = GetColorU32((hovered && held) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
|
|
RenderNavHighlight(bb, id);
|
|
RenderNavHighlight(bb, id);
|
|
RenderFrame(bb.Min, bb.Max, col, true, g.Style.FrameRounding);
|
|
RenderFrame(bb.Min, bb.Max, col, true, g.Style.FrameRounding);
|
|
- RenderArrow(bb.Min + g.Style.FramePadding, dir);
|
|
|
|
|
|
+ RenderArrow(bb.Min + ImVec2(ImMax(0.0f, size.x - g.FontSize - g.Style.FramePadding.x), ImMax(0.0f, size.y - g.FontSize - g.Style.FramePadding.y)), dir);
|
|
|
|
|
|
return pressed;
|
|
return pressed;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+bool ImGui::ArrowButton(const char* str_id, ImGuiDir dir)
|
|
|
|
+{
|
|
|
|
+ float sz = GetFrameHeight();
|
|
|
|
+ return ArrowButtonEx(str_id, dir, ImVec2(sz, sz), 0);
|
|
|
|
+}
|
|
|
|
+
|
|
// Tip: use ImGui::PushID()/PopID() to push indices or pointers in the ID stack.
|
|
// Tip: use ImGui::PushID()/PopID() to push indices or pointers in the ID stack.
|
|
// Then you can keep 'str_id' empty or the same for all your buttons (instead of creating a string based on a non-string id)
|
|
// Then you can keep 'str_id' empty or the same for all your buttons (instead of creating a string based on a non-string id)
|
|
bool ImGui::InvisibleButton(const char* str_id, const ImVec2& size_arg)
|
|
bool ImGui::InvisibleButton(const char* str_id, const ImVec2& size_arg)
|
|
@@ -10027,14 +10035,9 @@ template<typename TYPE, typename SIGNEDTYPE, typename FLOATTYPE>
|
|
static bool ImGui::SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, TYPE* v, const TYPE v_min, const TYPE v_max, const char* format, float power, ImGuiSliderFlags flags)
|
|
static bool ImGui::SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, TYPE* v, const TYPE v_min, const TYPE v_max, const char* format, float power, ImGuiSliderFlags flags)
|
|
{
|
|
{
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
- ImGuiWindow* window = GetCurrentWindow();
|
|
|
|
|
|
+ ImGuiWindow* window = g.CurrentWindow;
|
|
const ImGuiStyle& style = g.Style;
|
|
const ImGuiStyle& style = g.Style;
|
|
|
|
|
|
- // Draw frame
|
|
|
|
- const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : g.HoveredId == id ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg);
|
|
|
|
- RenderNavHighlight(bb, id);
|
|
|
|
- RenderFrame(bb.Min, bb.Max, frame_col, true, style.FrameRounding);
|
|
|
|
-
|
|
|
|
const bool is_horizontal = (flags & ImGuiSliderFlags_Vertical) == 0;
|
|
const bool is_horizontal = (flags & ImGuiSliderFlags_Vertical) == 0;
|
|
const bool is_decimal = (data_type == ImGuiDataType_Float) || (data_type == ImGuiDataType_Double);
|
|
const bool is_decimal = (data_type == ImGuiDataType_Float) || (data_type == ImGuiDataType_Double);
|
|
const bool is_power = (power != 1.0f) && is_decimal;
|
|
const bool is_power = (power != 1.0f) && is_decimal;
|
|
@@ -10195,10 +10198,16 @@ static bool ImGui::SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType d
|
|
}
|
|
}
|
|
|
|
|
|
// For 32-bits and larger types, slider bounds are limited to half the natural type range.
|
|
// For 32-bits and larger types, slider bounds are limited to half the natural type range.
|
|
-// So e.g. an integer Slider between INT_MAX-10 and INT_MAX will fail, but an integer Slider between INT_MAX/2-10 and INT_MAX/2.
|
|
|
|
-// It would be possible to life that limitation with some work but it doesn't seem to be work it for sliders.
|
|
|
|
|
|
+// So e.g. an integer Slider between INT_MAX-10 and INT_MAX will fail, but an integer Slider between INT_MAX/2-10 and INT_MAX/2 will be ok.
|
|
|
|
+// It would be possible to lift that limitation with some work but it doesn't seem to be worth it for sliders.
|
|
bool ImGui::SliderBehavior(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, void* v, const void* v_min, const void* v_max, const char* format, float power, ImGuiSliderFlags flags)
|
|
bool ImGui::SliderBehavior(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, void* v, const void* v_min, const void* v_max, const char* format, float power, ImGuiSliderFlags flags)
|
|
{
|
|
{
|
|
|
|
+ // Draw frame
|
|
|
|
+ ImGuiContext& g = *GImGui;
|
|
|
|
+ const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : g.HoveredId == id ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg);
|
|
|
|
+ RenderNavHighlight(bb, id);
|
|
|
|
+ RenderFrame(bb.Min, bb.Max, frame_col, true, g.Style.FrameRounding);
|
|
|
|
+
|
|
switch (data_type)
|
|
switch (data_type)
|
|
{
|
|
{
|
|
case ImGuiDataType_S32:
|
|
case ImGuiDataType_S32:
|
|
@@ -10474,7 +10483,7 @@ static bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed
|
|
if (g.IO.KeyShift)
|
|
if (g.IO.KeyShift)
|
|
adjust_delta *= 10.0f;
|
|
adjust_delta *= 10.0f;
|
|
}
|
|
}
|
|
- if (g.ActiveIdSource == ImGuiInputSource_Nav)
|
|
|
|
|
|
+ else if (g.ActiveIdSource == ImGuiInputSource_Nav)
|
|
{
|
|
{
|
|
int decimal_precision = (data_type == ImGuiDataType_Float || data_type == ImGuiDataType_Double) ? ImParseFormatPrecision(format, 3) : 0;
|
|
int decimal_precision = (data_type == ImGuiDataType_Float || data_type == ImGuiDataType_Double) ? ImParseFormatPrecision(format, 3) : 0;
|
|
adjust_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard|ImGuiNavDirSourceFlags_PadDPad, ImGuiInputReadMode_RepeatFast, 1.0f/10.0f, 10.0f).x;
|
|
adjust_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard|ImGuiNavDirSourceFlags_PadDPad, ImGuiInputReadMode_RepeatFast, 1.0f/10.0f, 10.0f).x;
|