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
Timeline strip header never runs under its controls (1024 px at 200 %): controls measured, step text, branches, step name and message elided to fit; timeline_overlaps UI test value
islandmed20cdd74ac745
diff --git a/CMakeLists.txt b/CMakeLists.txtindex 2300a233..5b975f9c 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -943,6 +943,7 @@ if(SCULPTFORGE_BUILD_TESTS)sculptforge_ui_test(menu_stable_720 menu_stable --size 1280x720)sculptforge_ui_test(title_version_1440 title_version --size 1440x900)sculptforge_ui_test(title_version_1024 title_version --size 1024x768)+ sculptforge_ui_test(timeline_narrow_1024 timeline_narrow --size 1024x768)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-timeline-elide.md b/changes/fix-timeline-elide.mdnew file mode 100644index 00000000..c77fcc03--- /dev/null+++ b/changes/fix-timeline-elide.md@@ -0,0 +1,8 @@+---+fixed: The Sculpt Timeline strip's header no longer runs under **Save with project** in a narrow window or at a high UI+ scale (a 1024 px window at 200 %): the step count, branches, step name and message are shortened with "..." to fit.+testers:+ - Windows at 200% scaling on a small window: Edit > Sculpt Timeline open, sculpt a few strokes; the header text+ ends with "..." before the Save with project checkbox, never under it.+---+Controls are measured instead of a fixed 250 px; UI test tests/ui/timeline_narrow.sfui (timeline_overlaps).diff --git a/src/app/App.h b/src/app/App.hindex 0697d7d1..c2d83209 100644--- a/src/app/App.h+++ b/src/app/App.h@@ -1612,6 +1612,7 @@ private:bool autosaveWritten_ = false;std::string windowTitle_;std::vector<std::pair<float, float>> barSpans_; // the top bar's widgets, x from-to, last frame (UI tests: no overlaps)+ std::vector<std::pair<float, float>> timelineSpans_; // the timeline header's pieces, x from-to (UI tests: no overlaps)// Parts (PanelParts.cpp): the panel, and Alt+click in the viewport to select one.void drawPartPopups();// Index of the nearest visible Part under the cursor (-1: none); builds stale BVHs on the way.diff --git a/src/app/PanelTimeline.cpp b/src/app/PanelTimeline.cppindex f68c81ae..d1b01e6d 100644--- a/src/app/PanelTimeline.cpp+++ b/src/app/PanelTimeline.cpp@@ -104,6 +104,17 @@ struct TimelineUiState {namespace {+// Shortens `text` with "..." to fit `width` (whole UTF-8 characters).+std::string fitText(const std::string& text, float width) {+ if (ImGui::CalcTextSize(text.c_str()).x <= width) return text;+ std::string t = text;+ while (!t.empty() && ImGui::CalcTextSize((t + "...").c_str()).x > width) {+ while (!t.empty() && (static_cast<unsigned char>(t.back()) & 0xC0) == 0x80) t.pop_back();+ if (!t.empty()) t.pop_back();+ }+ return t.empty() ? std::string() : t + "...";+}+std::string prefsFile(const std::string& configDir) { return configDir.empty() ? std::string() : configDir + "timeline.json"; }void loadPrefs(TimelineUiState& s, const std::string& configDir, bool deterministic) {@@ -443,25 +454,48 @@ void App::drawTimelineUi() {}const auto& path = t->path();const size_t n = path.size();- // Header row: what it is, where the cursor is, the controls.+ // Header row: what it is, where the cursor is, the controls. The controls are measured and right-aligned; the+ // text left of them is elided before it reaches them (a 1024 px window at 200 %), the step count last.+ const ImGuiStyle& st = ImGui::GetStyle();+ const float smallW = ImGui::CalcTextSize(ICON_LC_FILM).x + st.FramePadding.x * 2.0f; // SmallButton: same x padding+ const float checkW = ImGui::GetFrameHeight() + st.ItemInnerSpacing.x + ImGui::CalcTextSize(tr("Save with project")).x;+ const float controlsW = checkW + 2.0f * (smallW + st.ItemSpacing.x);+ const float controlsX = std::max(ImGui::GetCursorPosX(), ImGui::GetWindowWidth() - st.WindowPadding.x - controlsW);+ timelineSpans_.clear(); // (UI tests check that nothing overlaps)+ auto room = [&] { return controlsX - st.ItemSpacing.x - 8 * sc - (ImGui::GetItemRectMax().x - ImGui::GetWindowPos().x); };+ auto tail = [&](const std::string& text, const ImVec4* col) { // one more piece of the header, elided to the room left+ if (text.empty()) return;+ const float avail = room() - st.ItemSpacing.x;+ if (avail < ImGui::CalcTextSize("M...").x) return;+ const std::string shown = fitText(text, avail);+ ImGui::SameLine();+ if (col) ImGui::TextColored(*col, "%s", shown.c_str());+ else ImGui::TextDisabled("%s", shown.c_str());+ timelineSpans_.push_back({ImGui::GetItemRectMin().x, ImGui::GetItemRectMax().x});+ };ImGui::AlignTextToFramePadding();ImGui::TextUnformatted(ICON_LC_HISTORY);- ImGui::SameLine();- ImGui::Text(tr("Step %zu of %zu"), t->cursor(), n - 1);- if (!branches.empty()) {- ImGui::SameLine();- ImGui::TextDisabled(tr(branches.size() == 1 ? "%s %zu branch" : "%s %zu branches"), ICON_LC_GIT_BRANCH, branches.size());- }- if (const Timeline::Node& cur = t->node(t->cursorNode()); t->cursor() > 0) {- ImGui::SameLine();- ImGui::TextDisabled(" %s", cur.label.c_str());+ timelineSpans_.push_back({ImGui::GetItemRectMin().x, ImGui::GetItemRectMax().x});+ {+ char stepText[64];+ std::snprintf(stepText, sizeof stepText, tr("Step %zu of %zu"), t->cursor(), n - 1);+ const std::string shown = fitText(stepText, std::max(0.0f, room() - st.ItemSpacing.x));+ if (!shown.empty()) {+ ImGui::SameLine();+ ImGui::TextUnformatted(shown.c_str());+ timelineSpans_.push_back({ImGui::GetItemRectMin().x, ImGui::GetItemRectMax().x});+ }}- if (!s.message.empty()) {- ImGui::SameLine();- ImGui::TextColored(theme::textDim, " %s", s.message.c_str());+ if (!branches.empty()) {+ char branchText[64];+ std::snprintf(branchText, sizeof branchText, tr(branches.size() == 1 ? "%s %zu branch" : "%s %zu branches"), ICON_LC_GIT_BRANCH,+ branches.size());+ tail(branchText, nullptr);}- const float buttons = 250 * sc;- ImGui::SameLine(ImGui::GetWindowWidth() - buttons);+ if (const Timeline::Node& cur = t->node(t->cursorNode()); t->cursor() > 0) tail(" " + cur.label, nullptr);+ if (!s.message.empty()) tail(" " + s.message, &theme::textDim);+ ImGui::SameLine(controlsX);+ const float controlsStart = ImGui::GetCursorScreenPos().x;if (ImGui::Checkbox(tr("Save with project"), &s.saveHistory)) {Timeline::saveWithProject = s.saveHistory;savePrefs(s, configDir_, uiConfigDeterministic_);@@ -479,6 +513,7 @@ void App::drawTimelineUi() {savePrefs(s, configDir_, uiConfigDeterministic_);}ui::HelpText("Hide", nullptr, "Fold the timeline into a tab.", "Edit > Sculpt Timeline");+ timelineSpans_.push_back({controlsStart, ImGui::GetItemRectMax().x});// Branch lanes, then the track.ImDrawList* dl = ImGui::GetWindowDrawList();diff --git a/src/app/UiTest.cpp b/src/app/UiTest.cppindex 078d6876..b8b4cea9 100644--- a/src/app/UiTest.cpp+++ b/src/app/UiTest.cpp@@ -102,7 +102,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), 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), 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),@@ -942,17 +942,19 @@ double Demo::query(const std::string& name, bool& known) const {return double(n);}if (name == "shell_narrow") return app_.shell_.narrow ? 1.0 : 0.0;- if (name == "title_overlaps") { // top bar widgets drawn over each other last frame; names their spans in the log+ // Spans (x from-to) drawn over each other last frame; names them in the log.+ auto overlaps = [](const std::vector<std::pair<float, float>>& b, const char* what) {int n = 0;- const auto& b = app_.barSpans_;for (size_t i = 0; i < b.size(); ++i)for (size_t j = i + 1; j < b.size(); ++j)if (b[i].first < b[j].second - 0.5f && b[j].first < b[i].second - 0.5f) {- std::printf("title_overlaps: %.0f-%.0f and %.0f-%.0f\n", b[i].first, b[i].second, b[j].first, b[j].second);+ std::printf("%s: %.0f-%.0f and %.0f-%.0f\n", what, b[i].first, b[i].second, b[j].first, b[j].second);++n;}return n;- }+ };+ if (name == "title_overlaps") return overlaps(app_.barSpans_, "title_overlaps"); // top bar widgets over each other+ if (name == "timeline_overlaps") return overlaps(app_.timelineSpans_, "timeline_overlaps"); // the timeline header's piecesif (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();for (const std::string& o : off) std::fprintf(stderr, "offscreen: %s\n", o.c_str());diff --git a/tests/ui/timeline_narrow.sfui b/tests/ui/timeline_narrow.sfuinew file mode 100644index 00000000..c2acd0af--- /dev/null+++ b/tests/ui/timeline_narrow.sfui@@ -0,0 +1,27 @@+# The timeline strip's header never overlaps its controls: in a narrow window or at a high UI scale (a 1024 px window+# at 200 %) the step text, branch count, step name and message are elided before they reach "Save with project".+# CMake also runs this at 1024x768.+run ui_look look=classic layout=classic+run new_sphere subdivisions=4+stroke 0.35 0.40 0.60 0.45+stroke 0.40 0.55 0.62 0.60+run timeline_seek index=1+stroke 0.30 0.60 0.55 0.70+expect_value timeline_branches == 1+expect_value timeline_overlaps == 0+shot header++ui_scale 200+expect_value timeline_overlaps == 0+shot header_200+run ui_look look=forge layout=sculptforge+expect_value timeline_overlaps == 0+shot header_200_sculptforge++# 512 logical px at any window size (a 1024 px window at 200 %).+ui_scale auto+run ui_look look=classic layout=classic+logical_width 512+wait_idle 30+expect_value timeline_overlaps == 0+shot header_512