Forráskód Böngészése

Keep the software mouse cursor visible below 1920 by 1080

The pointer disappears while a Sunrise surface is open on any display smaller than the authored
geometry. It is drawn, but with no area.

`ImGuiStyle::ScaleAllSizes` truncates `MouseCursorScale` to a whole number:

    MouseCursorScale = ImTrunc(MouseCursorScale * scale_factor);

It starts at 1, so every scale factor below 1 leaves it at 0, and `RenderMouseCursor` then draws
the cursor into a rectangle of zero size. The atlas still carries the cursor and the position is
still correct, which is why the interface stays usable: buttons highlight and clicks land, with
nothing to aim them by.

The scale measures the viewport against 1920 by 1080, so it falls below 1 whenever the viewport is
narrower than about 1706 or shorter than 960:

    1920x1080   1.125  ->  1     visible
    1600x900    0.938  ->  0     invisible
    1366x768    0.900  ->  0     invisible
    1280x720    0.900  ->  0     invisible

Holding the cursor at its authored size changes nothing above the baseline: 2560 by 1440 and 3840
by 2160 already truncated to 1 and still do.

Checked in game at 1280 by 720 borderless, where the cursor was missing and now is not, and at
1920 by 1080 fullscreen, which was already correct and remains so.
Haze 3 hete
szülő
commit
441d3118c2
1 módosított fájl, 4 hozzáadás és 0 törlés
  1. 4 0
      Sunrise/src/core/ui/theme/sunrise_ui_theme.cpp

+ 4 - 0
Sunrise/src/core/ui/theme/sunrise_ui_theme.cpp

@@ -1,5 +1,6 @@
 #include "sunrise_ui_theme.h"
 
+#include <algorithm>
 #include <imgui.h>
 
 #include "../scaling/dpi/ui_dpi_scaling.h"
@@ -107,6 +108,9 @@ void apply() noexcept {
     // Scaling a fresh default style stops repeated monitor changes from building up error.
     const float scale = scaling::dpi::current();
     style.ScaleAllSizes(scale);
+    // ScaleAllSizes truncates this one to a whole number, so any factor below 1 zeroes it and the
+    // cursor draws with no area. Below the authored geometry it holds its authored size instead.
+    style.MouseCursorScale = (std::max)(1.0F, style.MouseCursorScale);
     style.FontSizeBase = fontSizeBase;
     style.FontScaleMain = scale;
     ImGui::GetStyle() = style;