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
Task menus hold still when they scroll: a menu taller than the screen widens by its scrollbar (Paint menu jitter at 1280x720 fullscreen)
islandmed43772b23bd46
diff --git a/CMakeLists.txt b/CMakeLists.txtindex ce636505..e336614f 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -878,6 +878,7 @@ if(SCULPTFORGE_BUILD_TESTS)# Studio mode: About shows the studio (tests/data/studio; core/StudioProfile.h).sculptforge_ui_test(studio_mode studio/studio_mode --studio ${CMAKE_CURRENT_SOURCE_DIR}/tests/data/studio/studio.json)sculptforge_ui_test(shell_layout_1080 shell_layout --size 1920x1080)+ sculptforge_ui_test(menu_stable_720 menu_stable --size 1280x720)sculptforge_ui_test(help_console_1080 help_console --size 1920x1080)# The S / U / I / O slider on a UI scaled 1.5x (Windows at 150%, #9): it must still open under the cursor.sculptforge_ui_test(size_popup_scaled size_popup --size 2400x1350)diff --git a/changes/fix-menu-jitter-fullscreen.md b/changes/fix-menu-jitter-fullscreen.mdnew file mode 100644index 00000000..4d08bcaf--- /dev/null+++ b/changes/fix-menu-jitter-fullscreen.md@@ -0,0 +1,9 @@+---+whats_new: **Paint menu**: no longer jitters on short screens (1280x720 fullscreen); a menu taller than the screen scrolls smoothly.+fixed: The **Paint** menu jittered on a short screen (reported at 1280x720 fullscreen, thanks ebarranco): taller than the+ space under the menu bar, it scrolled, its colour picker shrank under the scrollbar, the menu stopped scrolling and+ grew again, every frame. A menu that scrolls now widens by its scrollbar instead.+testers:+ - Any OS, a 1280x720 (or smaller) screen, fullscreen (F11): open Paint; the menu holds still and scrolls with the wheel.+---+Test: tests/ui/menu_stable.sfui (also at --size 1280x720, ui_menu_stable_720): menu_rect_changes == 0 for Paint, Sculpt, Render.diff --git a/src/app/App.h b/src/app/App.hindex a63c1f29..0a4a700e 100644--- a/src/app/App.h+++ b/src/app/App.h@@ -1518,6 +1518,8 @@ private:bool lookDirty_ = false; // uiPrefs_.look or the layout changed: applied at the start of the next shellCanvasRect focusRect_; // the tile under the pointer (tiled looks highlight its border)float menuX_ = 0.0f; // where the open task menu drops from+ ImVec4 menuRect_{}; // the open task menu's rect last frame, and how often it changed while open (UI tests)+ int menuRectChanges_ = 0;std::map<std::string, std::string> menuSection_; // each task menu's last section (palette id)void drawShelf(int shelf, const CanvasRect& rect);void drawShelfItem(int shelf, int index, const std::string& item, bool vertical);diff --git a/src/app/Shell.cpp b/src/app/Shell.cppindex 1851a0c6..527c6b5e 100644--- a/src/app/Shell.cpp+++ b/src/app/Shell.cpp@@ -1674,16 +1674,27 @@ void App::drawTaskMenu() {x = shell_.title.x + 150.0f * s;for (int i = 0; i < menuIndex; ++i) x += ImGui::CalcTextSize(taskMenus(count)[i].name).x + 18.0f * s;}- ImGui::SetNextWindowPos(ImVec2(std::clamp(x, 4.0f * s, vp->Size.x - w - 4.0f * s), y));- ImGui::SetNextWindowSizeConstraints(ImVec2(w, 0), ImVec2(w, vp->Size.y - y - 8.0f * s));+ // A menu taller than the space under the bar scrolls, and widens by the scrollbar: content that fits the width (the+ // Paint menu's colour picker and swatches) would otherwise get shorter under the scrollbar, stop scrolling, grow+ // again, and the menu jittered every frame (#bug-reports 11-06, 1280x720 fullscreen).+ const float sb = ImGui::GetStyle().ScrollbarSize;+ ImGui::SetNextWindowPos(ImVec2(std::clamp(x, 4.0f * s, vp->Size.x - w - sb - 4.0f * s), y));+ ImGui::SetNextWindowSizeConstraints(ImVec2(w, 0), ImVec2(w + sb, vp->Size.y - y - 8.0f * s));ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(pad, pad));const bool open = ImGui::BeginPopup("##palettedropdown");ImGui::PopStyleVar();if (!open) {dropdown_.clear();menuX_ = 0.0f;+ menuRect_ = ImVec4();return;}+ {+ const ImVec2 wp = ImGui::GetWindowPos(), ws = ImGui::GetWindowSize();+ const ImVec4 r(wp.x, wp.y, ws.x, ws.y);+ if (menuRect_.z > 0.0f && (r.x != menuRect_.x || r.y != menuRect_.y || r.z != menuRect_.z || r.w != menuRect_.w)) ++menuRectChanges_;+ menuRect_ = r;+ }ImDrawList* dl = ImGui::GetWindowDrawList();if (sections > 1) {ImGui::BeginGroup();diff --git a/src/app/UiTest.cpp b/src/app/UiTest.cppindex 7251fa87..f7560ecb 100644--- a/src/app/UiTest.cpp+++ b/src/app/UiTest.cpp@@ -95,7 +95,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, 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, 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// 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),@@ -788,6 +788,11 @@ double Demo::query(const std::string& name, bool& known) const {if (name == "right_tray_open") return app_.layout_.rightTrayOpen ? 1.0 : 0.0;if (name == "left_tray_open") return app_.layout_.leftTrayOpen ? 1.0 : 0.0;if (name == "right_tray_shown") return app_.shell_.rightTray.w > 0.0f ? 1.0 : 0.0; // drawn, not just set open (#107)+ if (name == "menu_rect_changes") { // times the open task menu moved or resized since the last read (a jitter is many)+ const int n = app_.menuRectChanges_;+ app_.menuRectChanges_ = 0;+ return double(n);+ }if (name == "shell_narrow") return app_.shell_.narrow ? 1.0 : 0.0;if (name == "offscreen_items") { // items drawn past the window's edge last frame (#105); names them in the logconst std::vector<std::string> off = Demo::offscreenItems();diff --git a/tests/ui/menu_stable.sfui b/tests/ui/menu_stable.sfuinew file mode 100644index 00000000..27e00455--- /dev/null+++ b/tests/ui/menu_stable.sfui@@ -0,0 +1,34 @@+# Discord #bug-reports 11-06: the Paint menu jittered in a 1280x720 fullscreen window. It is taller than the space under+# the menu bar, so it scrolls; its colour picker and swatches fit the menu's width, so the scrollbar narrowed them, the+# menu got short enough not to scroll, the scrollbar went, and so on every frame. CMake runs it at 1280x720+# (ui_menu_stable_720) too. Every task menu holds still once open.+run new_sphere subdivisions=3+ui_scale 100+wait_idle 30+click "Paint##menu.paint"+wait 0.3+print menu_rect_changes+wait 0.5+expect_value menu_rect_changes == 0+shot paint-menu+key escape+click "Sculpt##menu.sculpt"+wait 0.3+print menu_rect_changes+wait 0.5+expect_value menu_rect_changes == 0+key escape+click "Render##menu.render"+wait 0.3+print menu_rect_changes+wait 0.5+expect_value menu_rect_changes == 0+key escape+ui_scale 150+wait_idle 30+click "Paint##menu.paint"+wait 0.3+print menu_rect_changes+wait 0.5+expect_value menu_rect_changes == 0+key escape