mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-07 23:15:52 +01:00
Merge 93d05ee4f9a565bfff86b3e44e4b765c09a5f76d into 6aa6626f29227dd4b998c458cee52e41ba7fdf83
This commit is contained in:
commit
cf994317e4
@ -1581,6 +1581,8 @@ 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 sliders. Can be set between 0.0f (rectangle width is null) and 1.0f (full rectangle is drawn).
|
||||
SliderContrast = 0.5f; // Contrast between the left and right sides of the slider track.
|
||||
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 Image() calls.
|
||||
@ -3791,6 +3793,8 @@ 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, SliderContrast) }, // ImGuiStyleVar_SliderContrast
|
||||
{ 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
|
||||
|
||||
4
imgui.h
4
imgui.h
@ -1878,6 +1878,8 @@ enum ImGuiStyleVar_
|
||||
ImGuiStyleVar_ScrollbarSize, // float ScrollbarSize
|
||||
ImGuiStyleVar_ScrollbarRounding, // float ScrollbarRounding
|
||||
ImGuiStyleVar_ScrollbarPadding, // float ScrollbarPadding
|
||||
ImGuiStyleVar_SliderThickness, // float SliderThickness
|
||||
ImGuiStyleVar_SliderContrast, // float SliderContrast
|
||||
ImGuiStyleVar_GrabMinSize, // float GrabMinSize
|
||||
ImGuiStyleVar_GrabRounding, // float GrabRounding
|
||||
ImGuiStyleVar_ImageRounding, // float ImageRounding
|
||||
@ -2360,6 +2362,8 @@ 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; // Thickness of sliders. Can be set between 0.0f (rectangle width is null) and 1.0f (full rectangle is drawn),
|
||||
float SliderContrast; // Contrast between the left and right sides of the slider track.
|
||||
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.
|
||||
|
||||
@ -4495,6 +4495,10 @@ static void DemoWindowWidgetsVerticalSliders()
|
||||
const float spacing = 4;
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(spacing, spacing));
|
||||
|
||||
static float sliderThickness = 0.25f;
|
||||
ImGui::SliderFloat("Slider Thickness", &sliderThickness, 0.0f, 1.0f, "%.2f");
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_SliderThickness, sliderThickness);
|
||||
|
||||
static int int_value = 0;
|
||||
ImGui::VSliderInt("##int", ImVec2(18, 160), &int_value, 0, 5);
|
||||
ImGui::SameLine();
|
||||
@ -4508,11 +4512,12 @@ static void DemoWindowWidgetsVerticalSliders()
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBg, (ImVec4)ImColor::HSV(i / 7.0f, 0.5f, 0.5f));
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, (ImVec4)ImColor::HSV(i / 7.0f, 0.6f, 0.5f));
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBgActive, (ImVec4)ImColor::HSV(i / 7.0f, 0.7f, 0.5f));
|
||||
ImGui::PushStyleColor(ImGuiCol_SliderGrab, (ImVec4)ImColor::HSV(i / 7.0f, 0.9f, 0.9f));
|
||||
ImGui::PushStyleColor(ImGuiCol_SliderGrab, (ImVec4)ImColor::HSV(i / 7.0f, 0.8f, 0.7f));
|
||||
ImGui::PushStyleColor(ImGuiCol_SliderGrabActive, (ImVec4)ImColor::HSV(i / 7.0f,0.9f, 0.9f));
|
||||
ImGui::VSliderFloat("##v", ImVec2(18, 160), &values[i], 0.0f, 1.0f, "");
|
||||
if (ImGui::IsItemActive() || ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("%.3f", values[i]);
|
||||
ImGui::PopStyleColor(4);
|
||||
ImGui::PopStyleColor(5);
|
||||
ImGui::PopID();
|
||||
}
|
||||
ImGui::PopID();
|
||||
@ -4550,7 +4555,7 @@ static void DemoWindowWidgetsVerticalSliders()
|
||||
ImGui::PopID();
|
||||
}
|
||||
ImGui::PopID();
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::PopStyleVar(2);
|
||||
ImGui::TreePop();
|
||||
}
|
||||
}
|
||||
@ -8785,6 +8790,8 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
||||
SliderFloat("SeparatorTextBorderSize", &style.SeparatorTextBorderSize, 0.0f, 10.0f, "%.0f");
|
||||
SliderFloat2("SeparatorTextAlign", (float*)&style.SeparatorTextAlign, 0.0f, 1.0f, "%.2f");
|
||||
SliderFloat2("SeparatorTextPadding", (float*)&style.SeparatorTextPadding, 0.0f, 40.0f, "%.0f");
|
||||
SliderFloat("SliderThickness", &style.SliderThickness, 0.0f, 1.0f, "%.2f");
|
||||
SliderFloat("SliderContrast", &style.SliderContrast, -1.0f, 1.0f, "%.2f");
|
||||
SliderFloat("LogSliderDeadzone", &style.LogSliderDeadzone, 0.0f, 12.0f, "%.0f");
|
||||
SliderFloat("ImageRounding", &style.ImageRounding, 0.0f, 12.0f, "%.0f");
|
||||
SliderFloat("ImageBorderSize", &style.ImageBorderSize, 0.0f, max_border_size, "%.0f");
|
||||
|
||||
@ -3421,12 +3421,9 @@ 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);
|
||||
const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg, 1.0f + g.Style.SliderContrast);
|
||||
const ImU32 frame_col_after = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg, 1.0f - g.Style.SliderContrast);
|
||||
RenderNavCursor(frame_bb, id);
|
||||
RenderFrame(frame_bb.Min, 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);
|
||||
|
||||
// Slider behavior
|
||||
ImRect grab_bb;
|
||||
@ -3434,6 +3431,22 @@ bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* p_dat
|
||||
if (value_changed)
|
||||
MarkItemEdited(id);
|
||||
|
||||
// Render track
|
||||
ImRect draw_bb = frame_bb;
|
||||
if (g.Style.SliderThickness != 1.0f)
|
||||
{
|
||||
float shrink_amount = IM_ROUND((frame_bb.Max.y - frame_bb.Min.y) * 0.5f * (1.0f - g.Style.SliderThickness));
|
||||
draw_bb.Min.y += shrink_amount;
|
||||
draw_bb.Max.y -= shrink_amount;
|
||||
}
|
||||
//RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, false, style.FrameRounding);
|
||||
float mid_x = IM_ROUND(grab_bb.Min.x + (grab_bb.Max.x - grab_bb.Min.x) * 0.50f);
|
||||
window->DrawList->AddRectFilled(draw_bb.Min, ImVec2(mid_x, draw_bb.Max.y), frame_col, style.FrameRounding, ImDrawFlags_RoundLeft);
|
||||
window->DrawList->AddRectFilled(ImVec2(mid_x, draw_bb.Min.y), draw_bb.Max, frame_col_after, style.FrameRounding, ImDrawFlags_RoundRight);
|
||||
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);
|
||||
|
||||
// Render grab
|
||||
if (grab_bb.Max.x > grab_bb.Min.x)
|
||||
window->DrawList->AddRectFilled(grab_bb.Min, grab_bb.Max, GetColorU32(g.ActiveId == id ? ImGuiCol_SliderGrabActive : ImGuiCol_SliderGrab), style.GrabRounding);
|
||||
@ -3582,9 +3595,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);
|
||||
const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg, 1.0f + g.Style.SliderContrast);
|
||||
const ImU32 frame_col_after = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg, 1.0f - g.Style.SliderContrast);
|
||||
RenderNavCursor(frame_bb, id);
|
||||
RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, true, g.Style.FrameRounding);
|
||||
|
||||
// Slider behavior
|
||||
ImRect grab_bb;
|
||||
@ -3592,6 +3605,19 @@ bool ImGui::VSliderScalar(const char* label, const ImVec2& size, ImGuiDataType d
|
||||
if (value_changed)
|
||||
MarkItemEdited(id);
|
||||
|
||||
// Render track
|
||||
ImRect draw_bb = frame_bb;
|
||||
if (g.Style.SliderThickness != 1.0f)
|
||||
{
|
||||
float shrink_amount = (float)(int)((frame_bb.Max.x - frame_bb.Min.x) * 0.5f * (1.0f - g.Style.SliderThickness));
|
||||
draw_bb.Min.x += shrink_amount;
|
||||
draw_bb.Max.x -= shrink_amount;
|
||||
}
|
||||
//RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, true, g.Style.FrameRounding);
|
||||
float mid_y = IM_ROUND(grab_bb.Max.y - (grab_bb.Max.y - grab_bb.Min.y) * 0.50f);
|
||||
window->DrawList->AddRectFilled(ImVec2(draw_bb.Min.x, mid_y), draw_bb.Max, frame_col, style.FrameRounding, ImDrawFlags_RoundBottom);
|
||||
window->DrawList->AddRectFilled(draw_bb.Min, ImVec2(draw_bb.Max.x, mid_y), frame_col_after, style.FrameRounding, ImDrawFlags_RoundTop);
|
||||
|
||||
// Render grab
|
||||
if (grab_bb.Max.y > grab_bb.Min.y)
|
||||
window->DrawList->AddRectFilled(grab_bb.Min, grab_bb.Max, GetColorU32(g.ActiveId == id ? ImGuiCol_SliderGrabActive : ImGuiCol_SliderGrab), style.GrabRounding);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user