Skip to content

Free, open-source 3D sculpting for Linux, macOS and Windows: dense meshes, remeshing, painting, built-in AI (image/text to 3D), Send to Unreal, game-ready LODs, Gaussian splats and OpenUSD.

Pen navigation with stray driver mouse events (#7); S/U/I/O slider at the cursor that stays while dragged (#9)

islandmed24285fc73fad
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f5636cd1..c93b29d3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,14 @@ All notable changes to SculptForge are listed here. The format follows
## [Unreleased]
+### Fixed
+- Rotating, panning and zooming with the pen tip on the background only shook the view with some tablets (a Ugee
+ M708 on Linux, #7): their drivers send stray mouse events between the pen's, and the view followed both. The
+ pen now moves the view by its own motion only, and lifting the pen ends a view drag as it ends a stroke.
+- The S / U / I / O slider closed as soon as you grabbed it, and could open away from the cursor (#9, seen on
+ Windows). It now opens with its knob (the current value) right under the brush cursor, at any UI scale and
+ with a pen, and stays open while you drag until you let go, click elsewhere or press Esc.
+
## [0.9.4] - 2026-10-29
### Fixed
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ce4f6d43..e0114de3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -519,6 +519,10 @@ if(SCULPTFORGE_BUILD_TESTS)
add_test(NAME ui_help_console_1080 COMMAND sculptforge --ui-test ${CMAKE_CURRENT_SOURCE_DIR}/tests/ui/help_console.sfui
--size 1920x1080 --ui-out ${CMAKE_CURRENT_BINARY_DIR}/ui-shots/help_console_1080)
set_tests_properties(ui_help_console_1080 PROPERTIES LABELS ui TIMEOUT 300)
+ # The S / U / I / O slider on a UI scaled 1.5x (Windows at 150%, #9): it must still open under the cursor.
+ add_test(NAME ui_size_popup_scaled COMMAND sculptforge --ui-test ${CMAKE_CURRENT_SOURCE_DIR}/tests/ui/size_popup.sfui
+ --size 2400x1350 --ui-out ${CMAKE_CURRENT_BINARY_DIR}/ui-shots/size_popup_scaled)
+ set_tests_properties(ui_size_popup_scaled PROPERTIES LABELS ui TIMEOUT 300)
add_test(NAME ui_user_guide_1080 COMMAND sculptforge --ui-test ${CMAKE_CURRENT_SOURCE_DIR}/tests/ui/user_guide.sfui
--size 1920x1080 --ui-out ${CMAKE_CURRENT_BINARY_DIR}/ui-shots/user_guide_1080)
set_tests_properties(ui_user_guide_1080 PROPERTIES LABELS ui TIMEOUT 300)
diff --git a/docs/tablet.md b/docs/tablet.md
index cad82dc7..bbb66158 100644
--- a/docs/tablet.md
+++ b/docs/tablet.md
@@ -71,11 +71,15 @@ that pressure arrives at all, run `libinput debug-events` and look for `TABLET_T
pressure value, so a stroke begins where the pen starts pressing, never with a leftover value from the last
stroke. This is a few milliseconds at most.
- **Lifting the pen out of range mid-stroke**: the stroke ends there and is one undo step.
+- **The view shakes instead of turning when you drag the background with the pen** (0.9.4 and earlier, with
+ some Ugee and other drivers that also send mouse events): fixed in the next version; meanwhile the lower side
+ button (right-click) or the Rotate / Move / Zoom buttons beside the canvas turn the view.
## For developers
The settings and the curve are in `src/core/Tablet.h` (unit tests: `tests/test_tablet.cpp`); the pen event
handling and the preferences panel in `src/app/Tablet.cpp`. UI tests drive a simulated pen with real SDL pen
events plus the mouse events SDL synthesizes from them: `pen_stroke`, `pen_drag_item`, `pen_button`,
-`pen_hover`, `pen_pressure` and `pen_out` (documented in `src/app/UiTest.cpp`); `tests/ui/tablet.sfui` covers
-pressure, the curve, Pressure > Size, the eraser, side buttons, leaving proximity and the panel.
+`pen_hover`, `pen_drag`, `pen_pressure` and `pen_out` (documented in `src/app/UiTest.cpp`); `tests/ui/tablet.sfui`
+covers pressure, the curve, Pressure > Size, the eraser, side buttons, leaving proximity and the panel, and
+`tests/ui/pen_navigation.sfui` view drags with the pen tip, with and without a driver's stray mouse events.
diff --git a/src/app/App.cpp b/src/app/App.cpp
index 7b72d0ba..fb7665dc 100644
--- a/src/app/App.cpp
+++ b/src/app/App.cpp
@@ -755,6 +755,13 @@ void App::onMouseMove(float x, float y, float dx, float dy, bool fromPen) {
penLeft();
}
}
+ if (fromPen) {
+ // The pen moves by the distance from its last position taken here, not by SDL's xrel: SDL keeps one cursor
+ // position for the pen and every mouse, so with a driver's stray mouse events in between (a Ugee pen on
+ // X11, #7) each pen event's xrel jumped back from the stray position and the view shook instead of turning.
+ dx = x - mouseX_;
+ dy = y - mouseY_;
+ }
mouseX_ = x;
mouseY_ = y;
lastInputPen_ = fromPen;
diff --git a/src/app/Demo.h b/src/app/Demo.h
index f9428616..cb1571e8 100644
--- a/src/app/Demo.h
+++ b/src/app/Demo.h
@@ -111,7 +111,8 @@ private:
void penPressure(float pressure); // PEN_AXIS pressure
void penTouch(bool down, bool eraser); // PEN_DOWN / PEN_UP (+ left button)
void penButtonEvent(int button, bool down); // PEN_BUTTON_DOWN / UP (+ SDL 3.4's mouse button)
- void penStroke(std::function<ImVec2(float u)> path, float p0, float p1, bool eraser, bool leave, float seconds);
+ void penStroke(std::function<ImVec2(float u)> path, float p0, float p1, bool eraser, bool leave, float seconds,
+ std::function<void()> afterSample = {}); // afterSample: e.g. a driver's stray mouse event
// World -> screen in window coordinates.
ImVec2 project(const glm::vec3& p) const;
diff --git a/src/app/Pickers.cpp b/src/app/Pickers.cpp
index 5f9ba59b..daaa9ffa 100644
--- a/src/app/Pickers.cpp
+++ b/src/app/Pickers.cpp
@@ -94,7 +94,10 @@ struct State {
// Draw Size / Z Intensity / RGB Intensity / Focal Shift at the cursor.
int slider = -1; // PickerUi::Slider, -1 = closed
bool sliderSmooth = false; // Z Intensity of the Smooth brush (Shift was held)
- ImVec2 sliderAt{0, 0};
+ ImVec2 sliderAt{0, 0}; // the cursor when it opened
+ ImVec2 sliderPos{0, 0}; // the window's place, fixed once the knob is under sliderAt
+ bool sliderPlaced = false;
+ ImVec2 sliderKnob{0, 0};
int sliderFrame = -1;
std::string sliderTyped;
bool sliderWasActive = false;
@@ -953,7 +956,11 @@ void PickerUi::sizePopup(App& app, Slider which) {
State& s = st();
s.slider = int(which);
s.sliderSmooth = app.activeBrush() == BrushType::Smooth;
- s.sliderAt = ImGui::GetIO().MousePos;
+ // The brush cursor's own position (SDL's window coordinates, the brush ring's centre) rather than ImGui's
+ // MousePos: on Windows ImGui's comes from the global cursor minus the window position while no button is held,
+ // and pen drivers' stray mouse events move it too, so the slider opened away from the cursor (#9).
+ s.sliderAt = ImVec2(app.mouseX_, app.mouseY_);
+ s.sliderPlaced = false;
s.sliderFrame = ImGui::GetFrameCount();
s.sliderTyped.clear();
s.sliderWasActive = false;
@@ -1082,7 +1089,10 @@ void drawPickers(App& app) {
"inner ring of the cursor shows it.",
&app.focalShift_, -1.0f, 1.0f, 100.0f};
const float w = 200.0f * app.uiScale_;
- ImGui::SetNextWindowPos(ImVec2(s.sliderAt.x - w * 0.5f, s.sliderAt.y + 14.0f), ImGuiCond_Appearing);
+ // As in ZBrush the knob (the current value) opens right under the cursor, so pressing there drags it. The
+ // first frame (hidden while the window sizes itself) measures where the knob is; the window then stays put.
+ if (!s.sliderPlaced) s.sliderPos = ImVec2(s.sliderAt.x - w * 0.5f, s.sliderAt.y - ImGui::GetFrameHeight() * 0.5f);
+ ImGui::SetNextWindowPos(s.sliderPos, ImGuiCond_Always);
if (s.sliderFrame == ImGui::GetFrameCount()) ImGui::SetNextWindowFocus();
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 6.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(8, 8));
@@ -1132,14 +1142,33 @@ void drawPickers(App& app) {
*d.value = std::clamp(shown / d.shownScale, d.lo, d.hi);
}
ImGui::LogText("%s %.0f", d.name, double(*d.value * d.shownScale));
+ {
+ // The knob's centre as ImGui's slider draws it (2 px padding, GrabMinSize wide; Draw Size is logarithmic).
+ const ImVec2 lo = ImGui::GetItemRectMin(), hi = ImGui::GetItemRectMax();
+ const float grab = std::min(ImGui::GetStyle().GrabMinSize, hi.x - lo.x - 4.0f);
+ const float v = std::clamp(*d.value, d.lo, d.hi);
+ const float t = which == PickerUi::Slider::DrawSize ? std::log(v / d.lo) / std::log(d.hi / d.lo)
+ : (v - d.lo) / (d.hi - d.lo);
+ s.sliderKnob = ImVec2(lo.x + 2.0f + grab * 0.5f + t * (hi.x - lo.x - 4.0f - grab), (lo.y + hi.y) * 0.5f);
+ if (!s.sliderPlaced) {
+ const ImVec2 win = ImGui::GetWindowPos(), size = ImGui::GetWindowSize(), view = ImGui::GetIO().DisplaySize;
+ s.sliderPos = ImVec2(std::clamp(s.sliderAt.x - (s.sliderKnob.x - win.x), 0.0f, std::max(0.0f, view.x - size.x)),
+ std::clamp(s.sliderAt.y - (s.sliderKnob.y - win.y), 0.0f, std::max(0.0f, view.y - size.y)));
+ s.sliderPlaced = true;
+ }
+ }
ui::HelpText(d.name, d.key, d.help, "Draw");
- if (ImGui::IsItemActive())
+ const bool dragging = ImGui::IsItemActive();
+ if (dragging)
s.sliderWasActive = true;
else if (s.sliderWasActive)
close = true; // closes on release, as in ZBrush
+ // A click elsewhere closes it. (The press that grabs the knob is not one: ImGui reports the window as not
+ // hovered while its own slider is active, and that used to close the slider as soon as it was dragged, #9.)
const bool clicked =
ImGui::IsMouseClicked(ImGuiMouseButton_Left) || ImGui::IsMouseClicked(ImGuiMouseButton_Right);
- if (clicked && !first && !ImGui::IsWindowHovered()) close = true;
+ if (clicked && !first && !dragging && !ImGui::IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem))
+ close = true;
}
ImGui::End();
ImGui::PopStyleColor();
@@ -1148,6 +1177,13 @@ void drawPickers(App& app) {
}
}
+bool PickerUi::sliderKnob(ImVec2& knob) {
+ const State& s = st();
+ if (s.slider < 0 || !s.sliderPlaced) return false;
+ knob = s.sliderKnob;
+ return true;
+}
+
// ---------------------------------------------------------------------------
// The left tray's colour field: a saturation/value square, a slim hue strip and the main/second swatches. Drawn
// by hand rather than with ImGui::ColorPicker3 so its markers and corners match the rest of the shell.
diff --git a/src/app/Pickers.h b/src/app/Pickers.h
index 5b3aa5dc..5751dc49 100644
--- a/src/app/Pickers.h
+++ b/src/app/Pickers.h
@@ -56,6 +56,8 @@ struct PickerUi {
// held or Smooth is the brush), RGB Intensity or Focal Shift.
enum class Slider { DrawSize, ZIntensity, RgbIntensity, FocalShift };
static void sizePopup(App& app, Slider which);
+ // The open slider's knob (its current value) in window coordinates, as last drawn; false when none is open.
+ static bool sliderKnob(ImVec2& knob);
};
// Action id of a brush for the shelves ("brush.clay", "brush.paint", "brush.recipe.<name>").
diff --git a/src/app/Tablet.cpp b/src/app/Tablet.cpp
index b1785fa5..a76a9db0 100644
--- a/src/app/Tablet.cpp
+++ b/src/app/Tablet.cpp
@@ -58,7 +58,8 @@ void App::handlePenEvent(const SDL_Event& e) {
case SDL_EVENT_PEN_UP:
// End the stroke here rather than waiting for SDL's mouse button up: the pen may leave
// proximity right after, and some drivers then never send it.
- if (drag_ == Drag::Stroke && dragFromPen_) onMouseUp();
+ // The same for a tip drag on the background (rotate / pan / zoom); a side button's view drag goes on.
+ if (drag_ != Drag::None && dragFromPen_ && !penNavButton_) onMouseUp();
penTouching_ = penEraser_ = false;
penTracker_.touchUp();
break;
diff --git a/src/app/UiTest.cpp b/src/app/UiTest.cpp
index 680fd391..071e977e 100644
--- a/src/app/UiTest.cpp
+++ b/src/app/UiTest.cpp
@@ -51,7 +51,8 @@
// one in --ui-out/brush-library), ui_config (1 once Store Config wrote ui.json),
// console_open, command_palette_open, customize, shelves_visible,
// right_tray_open, left_tray_open, lightbox_open, guide_open, guide_hits (search results), shelves (1 shown), left_tray / right_tray (palettes in
-// the tray, -1 when closed); OP is == != < <= > >=
+// the tray, -1 when closed); OP is == != < <= > >=; N may be $NAME, $NAME*K,
+// $NAME+K or $NAME-K (see remember)
// moved (vertices moved since `snapshot`), moved_max / moved_sum (distance),
// moved_masked (masked vertices that moved),
// moved_out (summed movement along the snapshot's normals: > 0 out, < 0 in),
@@ -80,6 +81,7 @@
// last_stroke_dabs (dabs of the last finished stroke), stroke_type (0 Dots, 1 DragRect,
// 2 DragDot, 3 Spray, 4 LazyMouse), vdms (VDM brush maps), vdm_files (.sfvdm in the library)
// z_intensity, smooth_intensity, rgb_intensity (0-100), focal_shift (-100..100), draw_size,
+// size_popup_open (the S / U / I / O slider), size_knob_x / size_knob_y (its knob, pixels),
// quickmenu_open, lazy_mouse, input_style (0 ZBrush, 1 SculptForge), brush_type (BrushType
// index, -1 for a custom brush or Paint), last_dab_x / last_dab_y (window pixels), paint_r
// gizmo_mode (0 Draw, 1 Move, 2 Scale, 3 Rotate), gizmo_hover (handle under the cursor,
@@ -118,6 +120,9 @@
// pen_button N down|up side button N (1 lower, 2 upper, 3 third) with SDL 3.4's synthesized click
// pen_hover U V [S] move the hovering pen to a point on the model (drags the view while a
// button mapped to rotate / pan / right-click is held)
+// pen_drag X0 Y0 X1 Y1 [stray X Y] [S] pen tip drag from X0 Y0 to X1 Y1 (window fractions, like drag), e.g.
+// on the background to rotate the view; stray: a plain mouse event at X Y after every
+// pen sample, as some tablet drivers send (Ugee on X11, #7)
// pen_pressure P a pressure sample from the hovering pen (e.g. a stale value before a stroke)
// pen_out the pen leaves proximity
// mouse_move U V a plain mouse (not the pen) moves to a point on the model, e.g. the stray mouse
@@ -310,6 +315,11 @@ double Demo::query(const std::string& name, bool& known) const {
if (name == "focal_shift") return std::round(app_.focalShift_ * 100.0f);
if (name == "draw_size") return std::round(app_.radiusPx_);
if (name == "quickmenu_open") return app_.quickMenu_.open ? 1.0 : 0.0;
+ if (name == "size_popup_open" || name == "size_knob_x" || name == "size_knob_y") {
+ ImVec2 knob(-1.0f, -1.0f);
+ const bool open = PickerUi::sliderKnob(knob);
+ return name == "size_popup_open" ? (open ? 1.0 : 0.0) : name == "size_knob_x" ? knob.x : knob.y;
+ }
if (name == "lazy_mouse") return app_.strokeType_ == StrokeType::LazyMouse ? 1.0 : 0.0;
if (name == "stroke_type") return double(int(app_.strokeType_)); // 0 Dots, 1 DragRect, 2 DragDot, 3 Spray, 4 LazyMouse
if (name == "vdms") return double(app_.doc_.vdms.size());
@@ -1114,15 +1124,19 @@ bool Demo::parseStep(int line, const std::vector<std::string>& w, std::string& e
const std::string name = w[1], op = w[2], wantText = w[3];
run([this, line, name, op, wantText] {
double want = std::strtod(wantText.c_str(), nullptr);
- if (!wantText.empty() && wantText[0] == '$') { // $NAME or $NAME*K
- const size_t star = wantText.find('*');
- const std::string key = wantText.substr(1, star == std::string::npos ? std::string::npos : star - 1);
+ if (!wantText.empty() && wantText[0] == '$') { // $NAME, $NAME*K, $NAME+K or $NAME-K
+ const size_t op = wantText.find_first_of("*+-", 1);
+ const std::string key = wantText.substr(1, op == std::string::npos ? std::string::npos : op - 1);
const auto it = remembered_.find(key);
if (it == remembered_.end()) {
fail(line, "nothing remembered as $" + key);
return;
}
- want = it->second * (star == std::string::npos ? 1.0 : std::strtod(wantText.c_str() + star + 1, nullptr));
+ const double k = op == std::string::npos ? 0.0 : std::strtod(wantText.c_str() + op + 1, nullptr);
+ want = op == std::string::npos ? it->second
+ : wantText[op] == '*' ? it->second * k
+ : wantText[op] == '+' ? it->second + k
+ : it->second - k;
}
bool k = false;
const double v = query(name, k);
@@ -1239,6 +1253,40 @@ bool Demo::parseStep(int line, const std::vector<std::string>& w, std::string& e
return t >= seconds;
});
wait(0.05f);
+ } else if (verb == "pen_drag") {
+ if (!need(4)) return false;
+ const float x0 = num(1, 0), y0 = num(2, 0), x1 = num(3, 0), y1 = num(4, 0);
+ float seconds = 0.4f;
+ bool stray = false;
+ float sx = 0.0f, sy = 0.0f;
+ for (size_t i = 5; i < w.size(); ++i) {
+ if (w[i] == "stray" && i + 2 < w.size()) {
+ stray = true;
+ sx = num(i + 1, 0);
+ sy = num(i + 2, 0);
+ i += 2;
+ } else {
+ seconds = num(i, seconds);
+ }
+ }
+ auto ends = std::make_shared<std::pair<ImVec2, ImVec2>>();
+ run([this, ends, x0, y0, x1, y1] {
+ int ww = 0, wh = 0;
+ SDL_GetWindowSize(app_.window_, &ww, &wh);
+ *ends = {ImVec2(x0 * float(ww), y0 * float(wh)), ImVec2(x1 * float(ww), y1 * float(wh))};
+ });
+ // A stray mouse event at (sx, sy) after every pen sample, as some tablet drivers send.
+ std::function<void()> strayEvent;
+ if (stray)
+ strayEvent = [this, sx, sy] {
+ int ww = 0, wh = 0;
+ SDL_GetWindowSize(app_.window_, &ww, &wh);
+ mouseMotion(sx * float(ww), sy * float(wh));
+ };
+ penStroke([ends](float u) {
+ return ImVec2(ends->first.x + (ends->second.x - ends->first.x) * u, ends->first.y + (ends->second.y - ends->first.y) * u);
+ }, 0.5f, 0.5f, false, false, seconds, strayEvent);
+ wait(0.1f);
} else if (verb == "pen_pressure") {
if (!need(1)) return false;
run([this, p = num(1, 0)] {
@@ -1383,7 +1431,8 @@ void Demo::penButtonEvent(int button, bool down) {
if (button >= 1 && button < 5) mouseButton(down, kMouse[button], SDL_PEN_MOUSEID);
}
-void Demo::penStroke(std::function<ImVec2(float u)> path, float p0, float p1, bool eraser, bool leave, float seconds) {
+void Demo::penStroke(std::function<ImVec2(float u)> path, float p0, float p1, bool eraser, bool leave, float seconds,
+ std::function<void()> afterSample) {
// Hover to the start, touch down, then 4 samples a frame along the path, then lift (or leave).
auto from = std::make_shared<ImVec2>();
steps_.push_back([this, path, from](float t) {
@@ -1397,7 +1446,7 @@ void Demo::penStroke(std::function<ImVec2(float u)> path, float p0, float p1, bo
return t >= 0.25f;
});
auto last = std::make_shared<float>(-1.0f);
- steps_.push_back([this, path, p0, p1, eraser, leave, seconds, last](float t) {
+ steps_.push_back([this, path, p0, p1, eraser, leave, seconds, last, afterSample](float t) {
if (*last < 0.0f) {
penTouch(true, eraser);
penPressure(p0); // the first pressure sample comes after the touch
@@ -1411,6 +1460,7 @@ void Demo::penStroke(std::function<ImVec2(float u)> path, float p0, float p1, bo
penPressure(p0 + (p1 - p0) * uu);
const ImVec2 p = path(uu);
penMove(p.x, p.y);
+ if (afterSample) afterSample();
}
*last = u;
if (u < 1.0f) return false;
diff --git a/tests/ui/pen_navigation.sfui b/tests/ui/pen_navigation.sfui
new file mode 100644
index 00000000..15abab3b
--- /dev/null
+++ b/tests/ui/pen_navigation.sfui
@@ -0,0 +1,51 @@
+# Navigating with the pen tip (#7): a tip drag on the background rotates, Alt+drag pans, Ctrl+drag zooms, in both
+# input styles. Some tablet drivers (a Ugee pen on X11, Windows Ink) send stray mouse events at an old position
+# between the pen's; SDL keeps one cursor position for both, so its relative motion jumped back and forth and the
+# view only shook. With the stray events the view must move exactly as without them.
+run new_sphere subdivisions=4
+snapshot
+
+# Rotate: the same pen drag with and without stray events turns the view by the same angle.
+camera 0 0
+pen_drag 0.12 0.3 0.12 0.5
+remember camera_pitch clean
+expect_value camera_pitch < -20
+expect_value moved == 0
+camera 0 0
+pen_drag 0.12 0.3 0.12 0.5 stray 0.6 0.9
+expect_value camera_pitch >= $clean-0.5
+expect_value camera_pitch <= $clean+0.5
+expect_value moved == 0
+
+# Alt+drag pans, also with stray events.
+camera 0 0
+remember camera_pan p0
+hold alt
+pen_drag 0.12 0.3 0.12 0.5 stray 0.6 0.9
+hold none
+expect_value camera_pan > $p0
+expect_value moved == 0
+key f
+
+# The SculptForge input style: Ctrl+drag on the background zooms.
+click "Preferences##palette.preferences"
+click "Input##preferences.input"
+click "SculptForge##input.style_sculptforge"
+expect_value input_style == 1
+key escape
+remember camera_distance d0
+hold ctrl
+pen_drag 0.12 0.5 0.12 0.3 stray 0.6 0.9
+hold none
+expect_value camera_distance < $d0
+key f
+camera 0 0
+pen_drag 0.12 0.3 0.12 0.5 stray 0.6 0.9
+expect_value camera_pitch >= $clean-0.5
+expect_value camera_pitch <= $clean+0.5
+expect_value moved == 0
+
+# The pen still sculpts after navigating, and lifting it ended every drag.
+expect_value stroking == 0
+pen_stroke 0.3 0.45 0.7 0.55 0.6 0.6
+expect_value moved_out > 0
diff --git a/tests/ui/size_popup.sfui b/tests/ui/size_popup.sfui
new file mode 100644
index 00000000..68f2fb69
--- /dev/null
+++ b/tests/ui/size_popup.sfui
@@ -0,0 +1,58 @@
+# The S slider (Draw Size; U / I / O work the same) opens with its knob right under the cursor, as in ZBrush, and
+# stays open while it is dragged, until release, a click elsewhere or Esc (#9). CMake runs this script again on a
+# window whose UI is scaled 1.5x (ui_size_popup_scaled), like Windows at 150%.
+run new_sphere subdivisions=4
+
+# Opens at the cursor: the knob (the current size) is under it.
+mouse_move 0.5 0.5
+remember cursor_x cx
+remember cursor_y cy
+key s
+expect_value size_popup_open == 1
+expect_value size_knob_x >= $cx-2
+expect_value size_knob_x <= $cx+2
+expect_value size_knob_y >= $cy-2
+expect_value size_knob_y <= $cy+2
+shot opened
+
+# Dragging the knob, far outside the popup: it stays open and the size follows; letting go closes it.
+remember draw_size s0
+drag_path 0.5 0.5 1.2 0.5 keep
+expect_value size_popup_open == 1
+expect_value draw_size > $s0
+shot dragging
+release
+expect_value size_popup_open == 0
+
+# Somewhere else on the canvas, with the new size: the knob is still under the cursor. Esc closes it.
+mouse_move 0.25 0.7
+remember cursor_x cx2
+remember cursor_y cy2
+key s
+expect_value size_knob_x >= $cx2-2
+expect_value size_knob_x <= $cx2+2
+expect_value size_knob_y >= $cy2-2
+expect_value size_knob_y <= $cy2+2
+key escape
+expect_value size_popup_open == 0
+
+# A click outside closes it without changing the size.
+mouse_move 0.5 0.5
+key s
+remember draw_size s2
+drag 0.12 0.3 0.12 0.3
+expect_value size_popup_open == 0
+expect_value draw_size == $s2
+
+# A hovering pen with a driver's stray mouse event elsewhere: the slider opens at the pen (the brush cursor).
+pen_hover 0.4 0.5
+remember cursor_x px
+remember cursor_y py
+mouse_move 0.9 0.9
+key s
+expect_value size_knob_x >= $px-2
+expect_value size_knob_x <= $px+2
+expect_value size_knob_y >= $py-2
+expect_value size_knob_y <= $py+2
+key escape
+pen_out