Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1486,6 +1486,7 @@ ImGuiStyle::ImGuiStyle()
ScrollbarPadding = 2.0f; // Padding of scrollbar grab within its frame (same for both axes)
GrabMinSize = 12.0f; // Minimum width/height of a grab box for slider/scrollbar
GrabRounding = 0.0f; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
SliderThickness = 1.0f; // Thickness of slider background frame. From 0.0f to 1.0f
LogSliderDeadzone = 4.0f; // The size in pixels of the dead-zone around zero on logarithmic sliders that cross zero.
ImageRounding = 0.0f; // Rounding of Image() calls.
ImageBorderSize = 0.0f; // Thickness of border around tabs.
Expand Down Expand Up @@ -1566,6 +1567,7 @@ void ImGuiStyle::ScaleAllSizes(float scale_factor)
ScrollbarPadding = ImTrunc(ScrollbarPadding * scale_factor);
GrabMinSize = ImTrunc(GrabMinSize * scale_factor);
GrabRounding = ImTrunc(GrabRounding * scale_factor);
SliderThickness = ImTrunc(SliderThickness * scale_factor);
LogSliderDeadzone = ImTrunc(LogSliderDeadzone * scale_factor);
ImageRounding = ImTrunc(ImageRounding * scale_factor);
ImageBorderSize = ImTrunc(ImageBorderSize * scale_factor);
Expand Down Expand Up @@ -3634,6 +3636,7 @@ static const ImGuiStyleVarInfo GStyleVarsInfo[] =
{ 1, ImGuiDataType_Float, (ImU32)offsetof(ImGuiStyle, ScrollbarPadding) }, // ImGuiStyleVar_ScrollbarPadding
{ 1, ImGuiDataType_Float, (ImU32)offsetof(ImGuiStyle, GrabMinSize) }, // ImGuiStyleVar_GrabMinSize
{ 1, ImGuiDataType_Float, (ImU32)offsetof(ImGuiStyle, GrabRounding) }, // ImGuiStyleVar_GrabRounding
{ 1, ImGuiDataType_Float, (ImU32)offsetof(ImGuiStyle, SliderThickness) }, // ImGuiStyleVar_SliderThickness
{ 1, ImGuiDataType_Float, (ImU32)offsetof(ImGuiStyle, ImageRounding) }, // ImGuiStyleVar_ImageRounding
{ 1, ImGuiDataType_Float, (ImU32)offsetof(ImGuiStyle, ImageBorderSize) }, // ImGuiStyleVar_ImageBorderSize
{ 1, ImGuiDataType_Float, (ImU32)offsetof(ImGuiStyle, TabRounding) }, // ImGuiStyleVar_TabRounding
Expand Down
2 changes: 2 additions & 0 deletions imgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -1838,6 +1838,7 @@ enum ImGuiStyleVar_
ImGuiStyleVar_ScrollbarPadding, // float ScrollbarPadding
ImGuiStyleVar_GrabMinSize, // float GrabMinSize
ImGuiStyleVar_GrabRounding, // float GrabRounding
ImGuiStyleVar_SliderThickness, // float SliderThickness
ImGuiStyleVar_ImageRounding, // float ImageRounding
ImGuiStyleVar_ImageBorderSize, // float ImageBorderSize
ImGuiStyleVar_TabRounding, // float TabRounding
Expand Down Expand Up @@ -2309,6 +2310,7 @@ struct ImGuiStyle
float ScrollbarPadding; // Padding of scrollbar grab within its frame (same for both axes).
float GrabMinSize; // Minimum width/height of a grab box for slider/scrollbar.
float GrabRounding; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
float SliderThickness; //
float LogSliderDeadzone; // The size in pixels of the dead-zone around zero on logarithmic sliders that cross zero.
float ImageRounding; // Rounding of Image() calls.
float ImageBorderSize; // Thickness of border around Image() calls.
Expand Down
1 change: 1 addition & 0 deletions imgui_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8443,6 +8443,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
SliderFloat2("TouchExtraPadding", (float*)&style.TouchExtraPadding, 0.0f, 10.0f, "%.0f");
SliderFloat("IndentSpacing", &style.IndentSpacing, 0.0f, 30.0f, "%.0f");
SliderFloat("GrabMinSize", &style.GrabMinSize, 1.0f, 20.0f, "%.0f");
SliderFloat("SliderThickness", &style.SliderThickness, 0.1f, 1.0f, "%.3f");

SeparatorText("Borders");
SliderFloat("WindowBorderSize", &style.WindowBorderSize, 0.0f, max_border_size, "%.0f");
Expand Down
10 changes: 7 additions & 3 deletions imgui_widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3337,10 +3337,12 @@ bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* p_dat
// Draw frame
const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg);
RenderNavCursor(frame_bb, id);
RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, false, style.FrameRounding);
const float frame_thickness = frame_bb.Max.y - frame_bb.Min.y;
const ImRect bg_frame_bb(ImVec2(frame_bb.Min.x, frame_bb.Min.y + frame_thickness / 2 - style.SliderThickness * frame_thickness / 2), ImVec2(frame_bb.Max.x, frame_bb.Max.y - frame_thickness / 2 + style.SliderThickness * frame_thickness / 2));
RenderFrame(bg_frame_bb.Min, bg_frame_bb.Max, frame_col, false, style.FrameRounding);
if (color_marker != 0 && style.ColorMarkerSize > 0.0f)
RenderColorComponentMarker(frame_bb, GetColorU32(color_marker), style.FrameRounding);
RenderFrameBorder(frame_bb.Min, frame_bb.Max, g.Style.FrameRounding);
RenderFrameBorder(bg_frame_bb.Min, bg_frame_bb.Max, g.Style.FrameRounding);

// Slider behavior
ImRect grab_bb;
Expand Down Expand Up @@ -3492,7 +3494,9 @@ bool ImGui::VSliderScalar(const char* label, const ImVec2& size, ImGuiDataType d
// Draw frame
const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg);
RenderNavCursor(frame_bb, id);
RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, true, g.Style.FrameRounding);
const float frame_thickness = frame_bb.Max.x - frame_bb.Min.x;
const ImRect bg_frame_bb(ImVec2(frame_bb.Min.x + frame_thickness / 2 - style.SliderThickness * frame_thickness / 2, frame_bb.Min.y), ImVec2(frame_bb.Max.x - frame_thickness / 2 + style.SliderThickness * frame_thickness / 2, frame_bb.Max.y));
RenderFrame(bg_frame_bb.Min, bg_frame_bb.Max, frame_col, true, g.Style.FrameRounding);

// Slider behavior
ImRect grab_bb;
Expand Down