|
|
@@ -3851,7 +3851,7 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
|
|
|
const ImRect resize_rect(br - ImVec2(resize_corner_size * 0.75f, resize_corner_size * 0.75f), br);
|
|
|
const ImGuiID resize_id = window->GetID("#RESIZE");
|
|
|
bool hovered, held;
|
|
|
- ButtonBehavior(resize_rect, resize_id, &hovered, &held, true, ImGuiButtonFlags_FlattenChilds);
|
|
|
+ ButtonBehavior(resize_rect, resize_id, &hovered, &held, ImGuiButtonFlags_FlattenChilds);
|
|
|
resize_col = window->Color(held ? ImGuiCol_ResizeGripActive : hovered ? ImGuiCol_ResizeGripHovered : ImGuiCol_ResizeGrip);
|
|
|
|
|
|
if (hovered || held)
|
|
|
@@ -4112,7 +4112,7 @@ static void Scrollbar(ImGuiWindow* window, bool horizontal)
|
|
|
bool held = false;
|
|
|
bool hovered = false;
|
|
|
const bool previously_held = (g.ActiveId == id);
|
|
|
- ImGui::ButtonBehavior(bb, id, &hovered, &held, true);
|
|
|
+ ImGui::ButtonBehavior(bb, id, &hovered, &held);
|
|
|
|
|
|
float scroll_max = ImMax(1.0f, win_size_contents_v - win_size_avail_v);
|
|
|
float scroll_ratio = ImSaturate(scroll_v / scroll_max);
|
|
|
@@ -5130,7 +5130,7 @@ static inline bool IsWindowContentHoverable(ImGuiWindow* window)
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool* out_held, bool allow_key_modifiers, ImGuiButtonFlags flags)
|
|
|
+bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool* out_held, ImGuiButtonFlags flags)
|
|
|
{
|
|
|
ImGuiState& g = *GImGui;
|
|
|
ImGuiWindow* window = GetCurrentWindow();
|
|
|
@@ -5148,7 +5148,7 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
|
|
if (hovered)
|
|
|
{
|
|
|
SetHoveredID(id);
|
|
|
- if (allow_key_modifiers || (!g.IO.KeyCtrl && !g.IO.KeyShift && !g.IO.KeyAlt))
|
|
|
+ if (!(flags & ImGuiButtonFlags_NoKeyModifiers) || (!g.IO.KeyCtrl && !g.IO.KeyShift && !g.IO.KeyAlt))
|
|
|
{
|
|
|
if (g.IO.MouseClicked[0])
|
|
|
{
|
|
|
@@ -5219,7 +5219,7 @@ bool ImGui::ButtonEx(const char* label, const ImVec2& size_arg, ImGuiButtonFlags
|
|
|
|
|
|
if (window->DC.ButtonRepeat) flags |= ImGuiButtonFlags_Repeat;
|
|
|
bool hovered, held;
|
|
|
- bool pressed = ButtonBehavior(bb, id, &hovered, &held, true, flags);
|
|
|
+ bool pressed = ButtonBehavior(bb, id, &hovered, &held, flags);
|
|
|
|
|
|
// Render
|
|
|
const ImU32 col = window->Color((hovered && held) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
|
|
|
@@ -5265,7 +5265,7 @@ bool ImGui::InvisibleButton(const char* str_id, const ImVec2& size_arg)
|
|
|
return false;
|
|
|
|
|
|
bool hovered, held;
|
|
|
- bool pressed = ButtonBehavior(bb, id, &hovered, &held, true);
|
|
|
+ bool pressed = ButtonBehavior(bb, id, &hovered, &held);
|
|
|
|
|
|
return pressed;
|
|
|
}
|
|
|
@@ -5280,7 +5280,7 @@ static bool CloseWindowButton(bool* p_opened)
|
|
|
const ImRect bb(window->Rect().GetTR() + ImVec2(-2.0f-size,2.0f), window->Rect().GetTR() + ImVec2(-2.0f,2.0f+size));
|
|
|
|
|
|
bool hovered, held;
|
|
|
- bool pressed = ImGui::ButtonBehavior(bb, id, &hovered, &held, true);
|
|
|
+ bool pressed = ImGui::ButtonBehavior(bb, id, &hovered, &held);
|
|
|
|
|
|
// Render
|
|
|
const ImU32 col = window->Color((held && hovered) ? ImGuiCol_CloseButtonActive : hovered ? ImGuiCol_CloseButtonHovered : ImGuiCol_CloseButton);
|
|
|
@@ -5351,7 +5351,7 @@ bool ImGui::ImageButton(ImTextureID user_texture_id, const ImVec2& size, const I
|
|
|
return false;
|
|
|
|
|
|
bool hovered, held;
|
|
|
- bool pressed = ButtonBehavior(bb, id, &hovered, &held, true);
|
|
|
+ bool pressed = ButtonBehavior(bb, id, &hovered, &held);
|
|
|
|
|
|
// Render
|
|
|
const ImU32 col = window->Color((hovered && held) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
|
|
|
@@ -5557,7 +5557,7 @@ bool ImGui::CollapsingHeader(const char* label, const char* str_id, bool display
|
|
|
return opened;
|
|
|
|
|
|
bool hovered, held;
|
|
|
- bool pressed = ButtonBehavior(interact_bb, id, &hovered, &held, false);
|
|
|
+ bool pressed = ButtonBehavior(interact_bb, id, &hovered, &held, ImGuiButtonFlags_NoKeyModifiers);
|
|
|
if (pressed)
|
|
|
{
|
|
|
opened = !opened;
|
|
|
@@ -5947,7 +5947,7 @@ float ImGui::RoundScalar(float value, int decimal_precision)
|
|
|
return negative ? -value : value;
|
|
|
}
|
|
|
|
|
|
-bool ImGui::SliderBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v_min, float v_max, float power, int decimal_precision, bool horizontal)
|
|
|
+bool ImGui::SliderBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v_min, float v_max, float power, int decimal_precision, ImGuiSliderFlags flags)
|
|
|
{
|
|
|
ImGuiState& g = *GImGui;
|
|
|
ImGuiWindow* window = GetCurrentWindow();
|
|
|
@@ -5957,17 +5957,18 @@ bool ImGui::SliderBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v
|
|
|
RenderFrame(frame_bb.Min, frame_bb.Max, window->Color(ImGuiCol_FrameBg), true, style.FrameRounding);
|
|
|
|
|
|
const bool is_non_linear = fabsf(power - 1.0f) > 0.0001f;
|
|
|
+ const bool is_horizontal = (flags & ImGuiSliderFlags_Vertical) == 0;
|
|
|
|
|
|
const float grab_padding = 2.0f;
|
|
|
- const float slider_sz = horizontal ? (frame_bb.GetWidth() - grab_padding * 2.0f) : (frame_bb.GetHeight() - grab_padding * 2.0f);
|
|
|
+ const float slider_sz = is_horizontal ? (frame_bb.GetWidth() - grab_padding * 2.0f) : (frame_bb.GetHeight() - grab_padding * 2.0f);
|
|
|
float grab_sz;
|
|
|
if (decimal_precision > 0)
|
|
|
grab_sz = ImMin(style.GrabMinSize, slider_sz);
|
|
|
else
|
|
|
grab_sz = ImMin(ImMax(1.0f * (slider_sz / (v_max-v_min+1.0f)), style.GrabMinSize), slider_sz); // Integer sliders, if possible have the grab size represent 1 unit
|
|
|
const float slider_usable_sz = slider_sz - grab_sz;
|
|
|
- const float slider_usable_pos_min = (horizontal ? frame_bb.Min.x : frame_bb.Min.y) + grab_padding + grab_sz*0.5f;
|
|
|
- const float slider_usable_pos_max = (horizontal ? frame_bb.Max.x : frame_bb.Max.y) - grab_padding - grab_sz*0.5f;
|
|
|
+ const float slider_usable_pos_min = (is_horizontal ? frame_bb.Min.x : frame_bb.Min.y) + grab_padding + grab_sz*0.5f;
|
|
|
+ const float slider_usable_pos_max = (is_horizontal ? frame_bb.Max.x : frame_bb.Max.y) - grab_padding - grab_sz*0.5f;
|
|
|
|
|
|
// For logarithmic sliders that cross over sign boundary we want the exponential increase to be symmetric around 0.0f
|
|
|
float linear_zero_pos = 0.0f; // 0.0->1.0f
|
|
|
@@ -5990,9 +5991,9 @@ bool ImGui::SliderBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v
|
|
|
{
|
|
|
if (g.IO.MouseDown[0])
|
|
|
{
|
|
|
- const float mouse_abs_pos = horizontal ? g.IO.MousePos.x : g.IO.MousePos.y;
|
|
|
+ const float mouse_abs_pos = is_horizontal ? g.IO.MousePos.x : g.IO.MousePos.y;
|
|
|
float normalized_pos = ImClamp((mouse_abs_pos - slider_usable_pos_min) / slider_usable_sz, 0.0f, 1.0f);
|
|
|
- if (!horizontal)
|
|
|
+ if (!is_horizontal)
|
|
|
normalized_pos = 1.0f - normalized_pos;
|
|
|
|
|
|
float new_value;
|
|
|
@@ -6061,11 +6062,11 @@ bool ImGui::SliderBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v
|
|
|
}
|
|
|
|
|
|
// Draw
|
|
|
- if (!horizontal)
|
|
|
+ if (!is_horizontal)
|
|
|
grab_t = 1.0f - grab_t;
|
|
|
const float grab_pos = ImLerp(slider_usable_pos_min, slider_usable_pos_max, grab_t);
|
|
|
ImRect grab_bb;
|
|
|
- if (horizontal)
|
|
|
+ if (is_horizontal)
|
|
|
grab_bb = ImRect(ImVec2(grab_pos - grab_sz*0.5f, frame_bb.Min.y + grab_padding), ImVec2(grab_pos + grab_sz*0.5f, frame_bb.Max.y - grab_padding));
|
|
|
else
|
|
|
grab_bb = ImRect(ImVec2(frame_bb.Min.x + grab_padding, grab_pos - grab_sz*0.5f), ImVec2(frame_bb.Max.x - grab_padding, grab_pos + grab_sz*0.5f));
|
|
|
@@ -6129,7 +6130,7 @@ bool ImGui::SliderFloat(const char* label, float* v, float v_min, float v_max, c
|
|
|
ItemSize(total_bb, style.FramePadding.y);
|
|
|
|
|
|
// Actual slider behavior + render grab
|
|
|
- const bool value_changed = SliderBehavior(frame_bb, id, v, v_min, v_max, power, decimal_precision, true);
|
|
|
+ const bool value_changed = SliderBehavior(frame_bb, id, v, v_min, v_max, power, decimal_precision);
|
|
|
|
|
|
// Display value using user-provided display format so user can add prefix/suffix/decorations to the value.
|
|
|
char value_buf[64];
|
|
|
@@ -6175,7 +6176,7 @@ bool ImGui::VSliderFloat(const char* label, const ImVec2& size, float* v, float
|
|
|
}
|
|
|
|
|
|
// Actual slider behavior + render grab
|
|
|
- bool value_changed = SliderBehavior(frame_bb, id, v, v_min, v_max, power, decimal_precision, false);
|
|
|
+ bool value_changed = SliderBehavior(frame_bb, id, v, v_min, v_max, power, decimal_precision, ImGuiSliderFlags_Vertical);
|
|
|
|
|
|
// Display value using user-provided display format so user can add prefix/suffix/decorations to the value.
|
|
|
// For the vertical slider we allow centered text to overlap the frame padding
|
|
|
@@ -6754,7 +6755,7 @@ bool ImGui::Checkbox(const char* label, bool* v)
|
|
|
return false;
|
|
|
|
|
|
bool hovered, held;
|
|
|
- bool pressed = ButtonBehavior(total_bb, id, &hovered, &held, true);
|
|
|
+ bool pressed = ButtonBehavior(total_bb, id, &hovered, &held);
|
|
|
if (pressed)
|
|
|
*v = !(*v);
|
|
|
|
|
|
@@ -6817,7 +6818,7 @@ bool ImGui::RadioButton(const char* label, bool active)
|
|
|
const float radius = check_bb.GetHeight() * 0.5f;
|
|
|
|
|
|
bool hovered, held;
|
|
|
- bool pressed = ButtonBehavior(total_bb, id, &hovered, &held, true);
|
|
|
+ bool pressed = ButtonBehavior(total_bb, id, &hovered, &held);
|
|
|
|
|
|
window->DrawList->AddCircleFilled(center, radius, window->Color((held && hovered) ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg), 16);
|
|
|
if (active)
|
|
|
@@ -8003,7 +8004,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
|
|
|
if (flags & ImGuiSelectableFlags_MenuItem) button_flags |= ImGuiButtonFlags_PressedOnClick|ImGuiButtonFlags_PressedOnRelease;
|
|
|
if (flags & ImGuiSelectableFlags_Disabled) button_flags |= ImGuiButtonFlags_Disabled;
|
|
|
bool hovered, held;
|
|
|
- bool pressed = ButtonBehavior(bb_with_spacing, id, &hovered, &held, true, button_flags);
|
|
|
+ bool pressed = ButtonBehavior(bb_with_spacing, id, &hovered, &held, button_flags);
|
|
|
if (flags & ImGuiSelectableFlags_Disabled)
|
|
|
selected = false;
|
|
|
|
|
|
@@ -8359,7 +8360,7 @@ bool ImGui::ColorButton(const ImVec4& col, bool small_height, bool outline_borde
|
|
|
return false;
|
|
|
|
|
|
bool hovered, held;
|
|
|
- bool pressed = ButtonBehavior(bb, id, &hovered, &held, true);
|
|
|
+ bool pressed = ButtonBehavior(bb, id, &hovered, &held);
|
|
|
RenderFrame(bb.Min, bb.Max, window->Color(col), outline_border, style.FrameRounding);
|
|
|
|
|
|
if (hovered)
|