mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Style Added style.MouseCursorScale, may remove (#939).
This commit is contained in:
parent
6a83a9152f
commit
147ec8d1e2
13
imgui.cpp
13
imgui.cpp
@ -774,6 +774,7 @@ void ImGuiStyle::ScaleAllSizes(float scale_factor)
|
|||||||
GrabRounding = ImFloor(GrabRounding * scale_factor);
|
GrabRounding = ImFloor(GrabRounding * scale_factor);
|
||||||
DisplayWindowPadding = ImFloor(DisplayWindowPadding * scale_factor);
|
DisplayWindowPadding = ImFloor(DisplayWindowPadding * scale_factor);
|
||||||
DisplaySafeAreaPadding = ImFloor(DisplaySafeAreaPadding * scale_factor);
|
DisplaySafeAreaPadding = ImFloor(DisplaySafeAreaPadding * scale_factor);
|
||||||
|
MouseCursorScale = ImFloor(MouseCursorScale * scale_factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGuiIO::ImGuiIO()
|
ImGuiIO::ImGuiIO()
|
||||||
@ -3073,11 +3074,12 @@ void ImGui::Render()
|
|||||||
{
|
{
|
||||||
const ImVec2 pos = g.IO.MousePos - offset;
|
const ImVec2 pos = g.IO.MousePos - offset;
|
||||||
const ImTextureID tex_id = g.IO.Fonts->TexID;
|
const ImTextureID tex_id = g.IO.Fonts->TexID;
|
||||||
|
const float sc = g.Style.MouseCursorScale;
|
||||||
g.OverlayDrawList.PushTextureID(tex_id);
|
g.OverlayDrawList.PushTextureID(tex_id);
|
||||||
g.OverlayDrawList.AddImage(tex_id, pos+ImVec2(1,0), pos+ImVec2(1,0) + size, uv[2], uv[3], IM_COL32(0,0,0,48)); // Shadow
|
g.OverlayDrawList.AddImage(tex_id, pos + ImVec2(1,0)*sc, pos+ImVec2(1,0)*sc + size*sc, uv[2], uv[3], IM_COL32(0,0,0,48)); // Shadow
|
||||||
g.OverlayDrawList.AddImage(tex_id, pos+ImVec2(2,0), pos+ImVec2(2,0) + size, uv[2], uv[3], IM_COL32(0,0,0,48)); // Shadow
|
g.OverlayDrawList.AddImage(tex_id, pos + ImVec2(2,0)*sc, pos+ImVec2(2,0)*sc + size*sc, uv[2], uv[3], IM_COL32(0,0,0,48)); // Shadow
|
||||||
g.OverlayDrawList.AddImage(tex_id, pos, pos + size, uv[2], uv[3], IM_COL32(0,0,0,255)); // Black border
|
g.OverlayDrawList.AddImage(tex_id, pos, pos + size*sc, uv[2], uv[3], IM_COL32(0,0,0,255)); // Black border
|
||||||
g.OverlayDrawList.AddImage(tex_id, pos, pos + size, uv[0], uv[1], IM_COL32(255,255,255,255)); // White fill
|
g.OverlayDrawList.AddImage(tex_id, pos, pos + size*sc, uv[0], uv[1], IM_COL32(255,255,255,255)); // White fill
|
||||||
g.OverlayDrawList.PopTextureID();
|
g.OverlayDrawList.PopTextureID();
|
||||||
}
|
}
|
||||||
if (!g.OverlayDrawList.VtxBuffer.empty())
|
if (!g.OverlayDrawList.VtxBuffer.empty())
|
||||||
@ -4723,8 +4725,9 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
// Position tooltip (always follows mouse)
|
// Position tooltip (always follows mouse)
|
||||||
if ((flags & ImGuiWindowFlags_Tooltip) != 0 && !window_pos_set_by_api && !window_is_child_tooltip)
|
if ((flags & ImGuiWindowFlags_Tooltip) != 0 && !window_pos_set_by_api && !window_is_child_tooltip)
|
||||||
{
|
{
|
||||||
|
float sc = g.Style.MouseCursorScale;
|
||||||
ImVec2 ref_pos = g.IO.MousePos;
|
ImVec2 ref_pos = g.IO.MousePos;
|
||||||
ImRect rect_to_avoid(ref_pos.x - 16, ref_pos.y - 8, ref_pos.x + 24, ref_pos.y + 24); // FIXME: Completely hard-coded. Store boxes in mouse cursor data? Scale? Center on cursor hit-point?
|
ImRect rect_to_avoid(ref_pos.x - 16, ref_pos.y - 8, ref_pos.x + 24 * sc, ref_pos.y + 24 * sc); // FIXME: Hard-coded based on mouse cursor shape expectation. Exact dimension not very important.
|
||||||
window->PosFloat = FindBestWindowPosForPopup(ref_pos, window->Size, &window->AutoPosLastDirection, rect_to_avoid);
|
window->PosFloat = FindBestWindowPosForPopup(ref_pos, window->Size, &window->AutoPosLastDirection, rect_to_avoid);
|
||||||
if (window->AutoPosLastDirection == ImGuiDir_None)
|
if (window->AutoPosLastDirection == ImGuiDir_None)
|
||||||
window->PosFloat = ref_pos + ImVec2(2,2); // If there's not enough room, for tooltip we prefer avoiding the cursor at all cost even if it means that part of the tooltip won't be visible.
|
window->PosFloat = ref_pos + ImVec2(2,2); // If there's not enough room, for tooltip we prefer avoiding the cursor at all cost even if it means that part of the tooltip won't be visible.
|
||||||
|
1
imgui.h
1
imgui.h
@ -869,6 +869,7 @@ struct ImGuiStyle
|
|||||||
ImVec2 ButtonTextAlign; // Alignment of button text when button is larger than text. Defaults to (0.5f,0.5f) for horizontally+vertically centered.
|
ImVec2 ButtonTextAlign; // Alignment of button text when button is larger than text. Defaults to (0.5f,0.5f) for horizontally+vertically centered.
|
||||||
ImVec2 DisplayWindowPadding; // Window positions are clamped to be visible within the display area by at least this amount. Only covers regular windows.
|
ImVec2 DisplayWindowPadding; // Window positions are clamped to be visible within the display area by at least this amount. Only covers regular windows.
|
||||||
ImVec2 DisplaySafeAreaPadding; // If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. Covers popups/tooltips as well regular windows.
|
ImVec2 DisplaySafeAreaPadding; // If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. Covers popups/tooltips as well regular windows.
|
||||||
|
float MouseCursorScale; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). May be removed later.
|
||||||
bool AntiAliasedLines; // Enable anti-aliasing on lines/borders. Disable if you are really tight on CPU/GPU.
|
bool AntiAliasedLines; // Enable anti-aliasing on lines/borders. Disable if you are really tight on CPU/GPU.
|
||||||
bool AntiAliasedFill; // Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.)
|
bool AntiAliasedFill; // Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.)
|
||||||
float CurveTessellationTol; // Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
|
float CurveTessellationTol; // Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
|
||||||
|
Loading…
Reference in New Issue
Block a user