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.
C++ 3d3d-sculptingcppdear-imguidigital-sculptingfbxgame-developmentgaussian-splattinggltfimage-to-3dmcpopenglopenusdsculptingtext-to-3dunreal-engine
Side columns and trays never scroll sideways (dm4nd on Discord)
islandmed52af28905a95
diff --git a/CMakeLists.txt b/CMakeLists.txtindex 0818f1f0..db9365f3 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -978,6 +978,8 @@ if(SCULPTFORGE_BUILD_TESTS)sculptforge_ui_test(windows_dpi_2160 windows_dpi --size 2160x1350)# Part folders (#96) at 200 % on a 3200x1800 screen (tests/ui/hidpi/: scripts only run at their HiDPI size).sculptforge_ui_test(part_folders_hidpi hidpi/part_folders --size 3200x1800)+ # Trays and columns never scroll sideways at auto scale on a 1920x1200 screen (dm4nd on Discord).+ sculptforge_ui_test(tray_hscroll_hidpi hidpi/tray_hscroll --size 1920x1200)set_tests_properties(ui_right_tray_looks_720 ui_windows_dpi_2560 ui_windows_dpi_2160 PROPERTIES LABELS "ui;dpi" TIMEOUT 300)sculptforge_ui_test(user_guide_1080 user_guide --size 1920x1080)# The Deform panel for the look review (tests/ui/sizes/: scripts only run at their own sizes).diff --git a/changes/fix-tray-hscroll.md b/changes/fix-tray-hscroll.mdnew file mode 100644index 00000000..bb35bfcd--- /dev/null+++ b/changes/fix-tray-hscroll.md@@ -0,0 +1,9 @@+---+fixed: The side columns (the shelf with Undo and Redo, the brush and colour shelf) and the trays no longer scroll+ sideways. At some UI scales their tiles were a few pixels wider than the column, so a sideways swipe or scroll+ moved them; the tiles now fit the column and the trays only scroll up and down (dm4nd on Discord).+testers:+ - Windows, 1920x1200 fullscreen, display scaling 100 %, 125 % and 150 %, UI scale Auto: open Tool > Remesh in the+ right tray, swipe sideways on a trackpad (or Shift+wheel) over the tray and over the Undo/Redo column; nothing+ moves sideways and no tile is cut off at the edge.+---diff --git a/src/app/App.h b/src/app/App.hindex 5f6f1721..9820f741 100644--- a/src/app/App.h+++ b/src/app/App.h@@ -1747,7 +1747,8 @@ private:float canvasHeight() const { return canvasRect().h; }Renderer::Viewport canvasViewport(int fbWidth, int fbHeight) const; // the canvas in framebuffer pixelsvoid drawCanvasFrame();- bool canvasNavButton(const char* id, const char* icon, const char* label, int mode); // right-shelf Move/Zoom/Rotate+ // Right-shelf Move/Zoom/Rotate; width 0: the standard 44 px (times the UI scale).+ bool canvasNavButton(const char* id, const char* icon, const char* label, int mode, float width = 0.0f);void drawBrushTile(const char* id, ImVec2 size);void drawStrokeTile(const char* id, ImVec2 size);void drawStrokeIcon(ImDrawList* dl, ImVec2 a, ImVec2 b, StrokeType type); // the shelf tile's picturediff --git a/src/app/Shell.cpp b/src/app/Shell.cppindex 5cfe4a38..8926d75b 100644--- a/src/app/Shell.cpp+++ b/src/app/Shell.cpp@@ -85,6 +85,9 @@ bool beginShellWindow(const char* name, const CanvasRect& r, const ImVec4& bg, Ibool frame = true) {ImGui::SetNextWindowPos(ImVec2(r.x, r.y));ImGui::SetNextWindowSize(ImVec2(r.w, r.h));+ // Trays and side shelves scroll up and down only: a sideways wheel or swipe, or a widget a few pixels too wide,+ // never moves them sideways (dm4nd on Discord).+ if (r.h > r.w) ImGui::SetNextWindowScroll(ImVec2(0.0f, -1.0f));ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, padding);ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);@@ -2357,6 +2360,9 @@ void App::drawShelfItem(int shelf, int index, const std::string& item, bool vertauto centre = [&](float w) {if (vertical) ImGui::SetCursorPosX(std::max(padX, (winW - w) * 0.5f));};+ // A side column's items never run past its padding: wider than that, the column would scroll sideways (dm4nd on+ // Discord: at some UI scales the 76 / 44 px tiles were a few pixels wider than the column's inside).+ auto fitW = [&](float w) { return vertical ? std::min(w, std::floor(winW - 2.0f * padX)) : w; };const float rowH = 26.0f * s;if (item == "sep") {if (vertical) {@@ -2445,7 +2451,7 @@ void App::drawShelfItem(int shelf, int index, const std::string& item, bool vert"Micro: the micro triangles of the visible Parts' micro levels (Geometry > Micro).","Draw");} else if (item.rfind("widget.tile.", 0) == 0) {- const float w = (shell_.narrow ? 60.0f : 76.0f) * s;+ const float w = fitW((shell_.narrow ? 60.0f : 76.0f) * s);const ImVec2 size(w, w + (fontSmall_ ? fontSmall_->FontSize : 12.0f) + 4.0f * s);centre(w);if (item == "widget.tile.brush") drawBrushTile("##tile.brush", size);@@ -2454,15 +2460,16 @@ void App::drawShelfItem(int shelf, int index, const std::string& item, bool vertelse if (item == "widget.tile.material") drawMaterialTile("##tile.material", size);else ImGui::Dummy(size);} else if (item == "widget.color") {- const float w = (shell_.narrow ? 60.0f : 76.0f) * s;+ const float w = fitW((shell_.narrow ? 60.0f : 76.0f) * s);centre(w);drawColorWidget(w);} else if (item == "widget.nav.move" || item == "widget.nav.zoom" || item == "widget.nav.rotate") {- centre(44.0f * s);+ const float navW = fitW(44.0f * s);+ centre(navW);const int mode = item == "widget.nav.move" ? 0 : item == "widget.nav.zoom" ? 1 : 2;canvasNavButton(mode == 0 ? "nav.move" : mode == 1 ? "nav.zoom" : "nav.rotate",mode == 0 ? ICON_LC_HAND : mode == 1 ? ICON_LC_ZOOM_IN : ICON_LC_ROTATE_3D,- mode == 0 ? "Move" : mode == 1 ? "Zoom" : "Rotate", mode);+ mode == 0 ? "Move" : mode == 1 ? "Zoom" : "Rotate", mode, navW);} else if (item == "widget.add_brush") {const ImVec2 size(48.0f * s, shell::bottomShelfSize(layout_.shelfTiles).tileH * s);if (ImGui::InvisibleButton("##addbrush", size)) // the brush picker in "add to shelf" mode (Pickers.cpp)@@ -2523,7 +2530,7 @@ void App::drawShelfItem(int shelf, int index, const std::string& item, bool vert: a->icon ? (topShelfCompact_ ? ui::Look::Icon : ui::Look::IconLabel): ui::Look::Label;const ImVec2 size = shelf == kShelfTop ? ImVec2(look == ui::Look::Icon ? rowH : 0.0f, rowH)- : shelf == kShelfRight ? ImVec2(44.0f * s, 40.0f * s)+ : shelf == kShelfRight ? ImVec2(fitW(44.0f * s), 40.0f * s): shelf == kShelfBottom ? ImVec2(bottomTileW_, shell::bottomShelfSize(layout_.shelfTiles).tileH * s): ImVec2(winW - 2.0f * padX, 60.0f * s);centre(size.x);@@ -2748,10 +2755,10 @@ void App::finishShelfDrag() {}// Right-shelf Move / Zoom / Rotate: drag on the button to navigate.-bool App::canvasNavButton(const char* id, const char* icon, const char* englishLabel, int mode) {+bool App::canvasNavButton(const char* id, const char* icon, const char* englishLabel, int mode, float width) {const char* label = tr(englishLabel);const float s = uiScale_;- const ImVec2 size(44.0f * s, 40.0f * s);+ const ImVec2 size(width > 0.0f ? width : 44.0f * s, 40.0f * s);ImGui::InvisibleButton((std::string(label) + "##" + id).c_str(), size);const bool hovered = ImGui::IsItemHovered(), active = ImGui::IsItemActive();if (active) {diff --git a/src/app/UiTest.cpp b/src/app/UiTest.cppindex d9a47989..f421924d 100644--- a/src/app/UiTest.cpp+++ b/src/app/UiTest.cpp@@ -25,6 +25,7 @@// drag X0 Y0 X1 Y1 [S] [release] left-drag in window fractions (rectangle hide, sliders...); release:// let go of the held modifiers halfway (Alt-drag, release Alt to zoom)// drag_item LABEL DX DY [S] left-drag from the item by DX DY pixels (scrubbing, dragging a tile out)+// wheel_item LABEL X Y the mouse wheel over the item: X sideways (a trackpad swipe), Y up/down// drag_path U0 V0 U1 V1 ... [keep] [S=seconds] left-drag through the points (fractions of the model's// on-screen bounds; outside 0..1 is the background) with the held modifiers: a lasso,// or a rectangle from the first point to the last. keep: leave the button down@@ -102,7 +103,7 @@// user library), library_files (.sfbrush files in it; UI tests get an empty// one in --ui-out/brush-library), ui_config (1 once ui.json is written: the preferences save themselves, or Save Layout),// console_open, command_palette_open, customize, shelves_visible,-// right_tray_open, left_tray_open, right_tray_shown (drawn), shell_narrow, title_overlaps (top bar widgets over each other), timeline_overlaps (the timeline header's pieces over each other), menu_rect_changes (the open task menu moved or resized since last read), offscreen_items (past the window edge), Library_open, guide_open, guide_hits (search results), shelves (1 shown), left_tray / right_tray (palettes in+// right_tray_open, left_tray_open, right_tray_shown (drawn), shell_narrow, title_overlaps (top bar widgets over each other), timeline_overlaps (the timeline header's pieces over each other), menu_rect_changes (the open task menu moved or resized since last read), offscreen_items (past the window edge), hscroll_windows (shown vertical windows wider inside than out), hscrolled_windows (shown windows scrolled sideways), Library_open, guide_open, guide_hits (search results), shelves (1 shown), left_tray / right_tray (palettes in// 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),@@ -961,6 +962,25 @@ double Demo::query(const std::string& name, bool& known) const {for (const std::string& o : off) std::fprintf(stderr, "offscreen: %s\n", o.c_str());return double(off.size());}+ if (name == "hscrolled_windows") { // shown windows scrolled sideways now (a sideways wheel moved them); names them+ int n = 0;+ for (ImGuiWindow* w : ImGui::GetCurrentContext()->Windows)+ if (w->Active && !w->Hidden && std::abs(w->Scroll.x) > 0.5f) {+ std::fprintf(stderr, "hscrolled: %s (%.0f px)\n", w->Name, w->Scroll.x);+ ++n;+ }+ return n;+ }+ if (name == "hscroll_windows") { // shown vertical windows (trays, side shelves) wider inside than out; names them+ int n = 0;+ for (ImGuiWindow* w : ImGui::GetCurrentContext()->Windows)+ if (w->Active && !w->Hidden && w->Size.y > w->Size.x && w->ScrollMax.x > 0.5f &&+ !(w->Flags & (ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_Popup))) {+ std::fprintf(stderr, "hscroll: %s (%.0f px over %.0f)\n", w->Name, w->ScrollMax.x, w->Size.x);+ ++n;+ }+ return n;+ }if (name == "library_open") return app_.libraryBrowser_.open() ? 1.0 : 0.0;if (name == "guide_open") return app_.guide_.isOpen() ? 1.0 : 0.0;if (name == "guide_hits") return double(app_.guide_.searchHits());@@ -2756,6 +2776,30 @@ bool Demo::parseStep(int line, const std::vector<std::string>& w, std::string& eapp_.handleEvent(e);});wait(0.05f);+ } else if (verb == "wheel_item") { // wheel_item LABEL X Y: the wheel over a UI item; X is sideways (a trackpad swipe)+ if (!need(3)) return false;+ const std::string label = w[1];+ auto at = std::make_shared<ImVec2>();+ steps_.push_back([this, line, label, at](float t) {+ if (findItem(label, *at)) {+ mouseMotion(at->x, at->y);+ return true;+ }+ if (t > 3.0f) fail(line, notFound(label));+ return t > 3.0f;+ });+ wait(0.05f);+ run([this, at, dx = num(2, 0.0f), dy = num(3, 0.0f)] {+ SDL_Event e{};+ e.type = SDL_EVENT_MOUSE_WHEEL;+ e.wheel.windowID = SDL_GetWindowID(app_.window_);+ e.wheel.x = dx;+ e.wheel.y = dy;+ e.wheel.mouse_x = at->x;+ e.wheel.mouse_y = at->y;+ app_.handleEvent(e);+ });+ wait(0.1f);} else if (verb == "mouse_move") {if (!need(2)) return false;run([this, u = num(1, 0.5f), v = num(2, 0.5f)] {diff --git a/tests/ui/hidpi/tray_hscroll.sfui b/tests/ui/hidpi/tray_hscroll.sfuinew file mode 100644index 00000000..4ec6d762--- /dev/null+++ b/tests/ui/hidpi/tray_hscroll.sfui@@ -0,0 +1,34 @@+# Vertical trays and columns never scroll sideways (dm4nd on Discord, 0.11.13: auto UI scale, fullscreen 1920x1200, the+# right tray with Tool > Remesh open and the narrow Undo/Redo column scrolled horizontally). Every side column's items+# fit inside it (hscroll_windows: nothing wider inside than out), and a sideways swipe moves nothing (hscrolled_windows).+# CMake runs this at 1920x1200; logical_width plays the display scales Windows offers there (100 %, 125 %, 150 %), in+# the default look and in Classic.+ui_scale auto+run new_sphere subdivisions=3+click "Remesh##tool.remesh"+wait_idle 10+expect_value hscroll_windows == 0+wheel_item "Remesh##tool.remesh" -3 0+wheel_item "Undo##edit.undo" -3 0+expect_value hscrolled_windows == 0+shot remesh-100+logical_width 1536+wait_idle 30+expect_value hscroll_windows == 0+wheel_item "Remesh##tool.remesh" 3 0+expect_value hscrolled_windows == 0+shot remesh-125+logical_width 1280+wait_idle 30+expect_value hscroll_windows == 0+wheel_item "Undo##edit.undo" -3 0+expect_value hscrolled_windows == 0+shot remesh-150+run ui_look look=classic layout=classic+wait_idle 30+expect_value hscroll_windows == 0+shot classic-150+ui_scale 200+wait_idle 30+expect_value hscroll_windows == 0+shot classic-200