mirror of
https://github.com/ocornut/imgui.git
synced 2026-05-27 19:15:24 +08:00
Images, Style: added style.ImageRounding, ImGuiStyleVar_ImageRounding to configure rounding of Image() widgets. (#2942, #845)
Moving border drawing above AddImage() call, should not make a difference for square images.
This commit is contained in:
@@ -167,6 +167,9 @@ Other Changes:
|
|||||||
size. (#9166, #7623)
|
size. (#9166, #7623)
|
||||||
- Added GetItemFlags() in public API for consistency and to expose generic
|
- Added GetItemFlags() in public API for consistency and to expose generic
|
||||||
flags of last submitted item. (#9127)
|
flags of last submitted item. (#9127)
|
||||||
|
- Images:
|
||||||
|
- Added style.ImageRounding, ImGuiStyleVar_ImageRounding to configure
|
||||||
|
rounding of Image() widgets. (#2942, #845)
|
||||||
- Shortcuts:
|
- Shortcuts:
|
||||||
- IsItemHovered() without ImGuiHoveredFlags_AllowWhenBlockedByActiveItem
|
- IsItemHovered() without ImGuiHoveredFlags_AllowWhenBlockedByActiveItem
|
||||||
doesn't filter out the signal when activated item is a shortcut remote activation;
|
doesn't filter out the signal when activated item is a shortcut remote activation;
|
||||||
|
|||||||
@@ -1470,6 +1470,7 @@ ImGuiStyle::ImGuiStyle()
|
|||||||
GrabMinSize = 12.0f; // Minimum width/height of a grab box for slider/scrollbar
|
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.
|
GrabRounding = 0.0f; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
|
||||||
LogSliderDeadzone = 4.0f; // The size in pixels of the dead-zone around zero on logarithmic sliders that cross zero.
|
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.
|
ImageBorderSize = 0.0f; // Thickness of border around tabs.
|
||||||
TabRounding = 5.0f; // Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs.
|
TabRounding = 5.0f; // Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs.
|
||||||
TabBorderSize = 0.0f; // Thickness of border around tabs.
|
TabBorderSize = 0.0f; // Thickness of border around tabs.
|
||||||
@@ -1544,6 +1545,7 @@ void ImGuiStyle::ScaleAllSizes(float scale_factor)
|
|||||||
GrabMinSize = ImTrunc(GrabMinSize * scale_factor);
|
GrabMinSize = ImTrunc(GrabMinSize * scale_factor);
|
||||||
GrabRounding = ImTrunc(GrabRounding * scale_factor);
|
GrabRounding = ImTrunc(GrabRounding * scale_factor);
|
||||||
LogSliderDeadzone = ImTrunc(LogSliderDeadzone * scale_factor);
|
LogSliderDeadzone = ImTrunc(LogSliderDeadzone * scale_factor);
|
||||||
|
ImageRounding = ImTrunc(ImageRounding * scale_factor);
|
||||||
ImageBorderSize = ImTrunc(ImageBorderSize * scale_factor);
|
ImageBorderSize = ImTrunc(ImageBorderSize * scale_factor);
|
||||||
TabRounding = ImTrunc(TabRounding * scale_factor);
|
TabRounding = ImTrunc(TabRounding * scale_factor);
|
||||||
TabMinWidthBase = ImTrunc(TabMinWidthBase * scale_factor);
|
TabMinWidthBase = ImTrunc(TabMinWidthBase * scale_factor);
|
||||||
@@ -3603,6 +3605,7 @@ static const ImGuiStyleVarInfo GStyleVarsInfo[] =
|
|||||||
{ 1, ImGuiDataType_Float, (ImU32)offsetof(ImGuiStyle, ScrollbarPadding) }, // ImGuiStyleVar_ScrollbarPadding
|
{ 1, ImGuiDataType_Float, (ImU32)offsetof(ImGuiStyle, ScrollbarPadding) }, // ImGuiStyleVar_ScrollbarPadding
|
||||||
{ 1, ImGuiDataType_Float, (ImU32)offsetof(ImGuiStyle, GrabMinSize) }, // ImGuiStyleVar_GrabMinSize
|
{ 1, ImGuiDataType_Float, (ImU32)offsetof(ImGuiStyle, GrabMinSize) }, // ImGuiStyleVar_GrabMinSize
|
||||||
{ 1, ImGuiDataType_Float, (ImU32)offsetof(ImGuiStyle, GrabRounding) }, // ImGuiStyleVar_GrabRounding
|
{ 1, ImGuiDataType_Float, (ImU32)offsetof(ImGuiStyle, GrabRounding) }, // ImGuiStyleVar_GrabRounding
|
||||||
|
{ 1, ImGuiDataType_Float, (ImU32)offsetof(ImGuiStyle, ImageRounding) }, // ImGuiStyleVar_ImageRounding
|
||||||
{ 1, ImGuiDataType_Float, (ImU32)offsetof(ImGuiStyle, ImageBorderSize) }, // ImGuiStyleVar_ImageBorderSize
|
{ 1, ImGuiDataType_Float, (ImU32)offsetof(ImGuiStyle, ImageBorderSize) }, // ImGuiStyleVar_ImageBorderSize
|
||||||
{ 1, ImGuiDataType_Float, (ImU32)offsetof(ImGuiStyle, TabRounding) }, // ImGuiStyleVar_TabRounding
|
{ 1, ImGuiDataType_Float, (ImU32)offsetof(ImGuiStyle, TabRounding) }, // ImGuiStyleVar_TabRounding
|
||||||
{ 1, ImGuiDataType_Float, (ImU32)offsetof(ImGuiStyle, TabBorderSize) }, // ImGuiStyleVar_TabBorderSize
|
{ 1, ImGuiDataType_Float, (ImU32)offsetof(ImGuiStyle, TabBorderSize) }, // ImGuiStyleVar_TabBorderSize
|
||||||
|
|||||||
@@ -1830,6 +1830,7 @@ enum ImGuiStyleVar_
|
|||||||
ImGuiStyleVar_ScrollbarPadding, // float ScrollbarPadding
|
ImGuiStyleVar_ScrollbarPadding, // float ScrollbarPadding
|
||||||
ImGuiStyleVar_GrabMinSize, // float GrabMinSize
|
ImGuiStyleVar_GrabMinSize, // float GrabMinSize
|
||||||
ImGuiStyleVar_GrabRounding, // float GrabRounding
|
ImGuiStyleVar_GrabRounding, // float GrabRounding
|
||||||
|
ImGuiStyleVar_ImageRounding, // float ImageRounding
|
||||||
ImGuiStyleVar_ImageBorderSize, // float ImageBorderSize
|
ImGuiStyleVar_ImageBorderSize, // float ImageBorderSize
|
||||||
ImGuiStyleVar_TabRounding, // float TabRounding
|
ImGuiStyleVar_TabRounding, // float TabRounding
|
||||||
ImGuiStyleVar_TabBorderSize, // float TabBorderSize
|
ImGuiStyleVar_TabBorderSize, // float TabBorderSize
|
||||||
@@ -2300,6 +2301,7 @@ struct ImGuiStyle
|
|||||||
float GrabMinSize; // Minimum width/height of a grab box for slider/scrollbar.
|
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 GrabRounding; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
|
||||||
float LogSliderDeadzone; // The size in pixels of the dead-zone around zero on logarithmic sliders that cross zero.
|
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.
|
float ImageBorderSize; // Thickness of border around Image() calls.
|
||||||
float TabRounding; // Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs.
|
float TabRounding; // Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs.
|
||||||
float TabBorderSize; // Thickness of border around tabs.
|
float TabBorderSize; // Thickness of border around tabs.
|
||||||
|
|||||||
@@ -8459,6 +8459,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
|||||||
SliderFloat2("SeparatorTextAlign", (float*)&style.SeparatorTextAlign, 0.0f, 1.0f, "%.2f");
|
SliderFloat2("SeparatorTextAlign", (float*)&style.SeparatorTextAlign, 0.0f, 1.0f, "%.2f");
|
||||||
SliderFloat2("SeparatorTextPadding", (float*)&style.SeparatorTextPadding, 0.0f, 40.0f, "%.0f");
|
SliderFloat2("SeparatorTextPadding", (float*)&style.SeparatorTextPadding, 0.0f, 40.0f, "%.0f");
|
||||||
SliderFloat("LogSliderDeadzone", &style.LogSliderDeadzone, 0.0f, 12.0f, "%.0f");
|
SliderFloat("LogSliderDeadzone", &style.LogSliderDeadzone, 0.0f, 12.0f, "%.0f");
|
||||||
|
SliderFloat("ImageRounding", &style.ImageRounding, 0.0f, 12.0f, "%.0f");
|
||||||
SliderFloat("ImageBorderSize", &style.ImageBorderSize, 0.0f, 1.0f, "%.0f");
|
SliderFloat("ImageBorderSize", &style.ImageBorderSize, 0.0f, 1.0f, "%.0f");
|
||||||
|
|
||||||
SeparatorText("Tooltips");
|
SeparatorText("Tooltips");
|
||||||
|
|||||||
+8
-4
@@ -1130,11 +1130,15 @@ void ImGui::ImageWithBg(ImTextureRef tex_ref, const ImVec2& image_size, const Im
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Render
|
// Render
|
||||||
if (g.Style.ImageBorderSize > 0.0f)
|
float rounding = g.Style.ImageRounding;
|
||||||
window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_Border), 0.0f, ImDrawFlags_None, g.Style.ImageBorderSize);
|
|
||||||
if (bg_col.w > 0.0f)
|
if (bg_col.w > 0.0f)
|
||||||
window->DrawList->AddRectFilled(bb.Min + padding, bb.Max - padding, GetColorU32(bg_col));
|
window->DrawList->AddRectFilled(bb.Min + padding, bb.Max - padding, GetColorU32(bg_col), rounding);
|
||||||
window->DrawList->AddImage(tex_ref, bb.Min + padding, bb.Max - padding, uv0, uv1, GetColorU32(tint_col));
|
if (rounding > 0.0f)
|
||||||
|
window->DrawList->AddImageRounded(tex_ref, bb.Min + padding, bb.Max - padding, uv0, uv1, GetColorU32(tint_col), rounding);
|
||||||
|
else
|
||||||
|
window->DrawList->AddImage(tex_ref, bb.Min + padding, bb.Max - padding, uv0, uv1, GetColorU32(tint_col));
|
||||||
|
if (g.Style.ImageBorderSize > 0.0f)
|
||||||
|
window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_Border), rounding, ImDrawFlags_None, g.Style.ImageBorderSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::Image(ImTextureRef tex_ref, const ImVec2& image_size, const ImVec2& uv0, const ImVec2& uv1)
|
void ImGui::Image(ImTextureRef tex_ref, const ImVec2& image_size, const ImVec2& uv0, const ImVec2& uv1)
|
||||||
|
|||||||
Reference in New Issue
Block a user