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
Undo and Redo on the right shelf (#43); stored layouts get them at the top once (layout version 3)
islandmed7760b03cd486
diff --git a/src/app/UiLayout.cpp b/src/app/UiLayout.cppindex 7c1eb98a..003865a5 100644--- a/src/app/UiLayout.cpp+++ b/src/app/UiLayout.cpp@@ -36,7 +36,8 @@ UiLayout standardLayout() {"transform.symmetry_x", "transform.symmetry_y", "transform.symmetry_z", "sep", "draw.pressure_strength","draw.pressure_size", "widget.points"};l.leftShelf = {"widget.tile.brush", "widget.tile.stroke", "widget.tile.alpha", "widget.tile.material", "widget.color"};- l.rightShelf = {"view.frame", "widget.nav.move", "widget.nav.zoom", "widget.nav.rotate", "sep",+ l.rightShelf = {"edit.undo", "edit.redo", "sep",+ "view.frame", "widget.nav.move", "widget.nav.zoom", "widget.nav.rotate", "sep","view.polyf", "view.polygroups", "view.mask", "view.polypaint", "sep","subtool.solo", "view.splats"};l.bottomShelf = {"brush.standard", "brush.clay", "brush.claybuildup", "brush.damstandard", "brush.move",@@ -101,6 +102,11 @@ bool fromJson(const Json& j, UiLayout& l, std::string& error) {}readStrings(j["leftShelf"], out.leftShelf);readStrings(j["rightShelf"], out.rightShelf);+ // Version 3 added Undo and Redo at the top of the right shelf (#43): put them into stored ones.+ if (int(j["version"].asNumber(1)) < 3 && j["rightShelf"].isArray() &&+ std::find(out.rightShelf.begin(), out.rightShelf.end(), "edit.undo") == out.rightShelf.end() &&+ std::find(out.rightShelf.begin(), out.rightShelf.end(), "edit.redo") == out.rightShelf.end())+ out.rightShelf.insert(out.rightShelf.begin(), {"edit.undo", "edit.redo", "sep"});readStrings(j["bottomShelf"], out.bottomShelf);flag("consoleOpen", out.consoleOpen);number("consoleHeight", out.consoleHeight);diff --git a/src/app/UiLayout.h b/src/app/UiLayout.hindex ba573afa..423bb217 100644--- a/src/app/UiLayout.h+++ b/src/app/UiLayout.h@@ -20,7 +20,7 @@ struct CanvasRect {};struct UiLayout {- int version = 2; // 2: the top shelf has Dynamic (older stored layouts get it on load)+ int version = 3; // 2: the top shelf has Dynamic; 3: the right shelf has Undo / Redo (older stored layouts get them on load)bool shelvesVisible = true, paletteBarVisible = true, leftHanded = false;bool leftTrayOpen = false, rightTrayOpen = true;float leftTrayWidth = 300, rightTrayWidth = 300; // logical pxdiff --git a/tests/test_shell_layout.cpp b/tests/test_shell_layout.cppindex 82a50e7f..338f12bd 100644--- a/tests/test_shell_layout.cpp+++ b/tests/test_shell_layout.cpp@@ -9,6 +9,8 @@#include "app/ShellGeometry.h"#include <cmath>+#include <string>+#include <vector>using namespace sf;@@ -16,6 +18,12 @@ namespace {bool near(float a, float b) { return std::abs(a - b) < 0.01f; }+Json shelfJson(const std::vector<std::string>& ids) {+ Json a = Json::array();+ for (const auto& id : ids) a.push(id);+ return a;+}+bool rectIs(const CanvasRect& r, float x, float y, float w, float h) {return near(r.x, x) && near(r.y, y) && near(r.w, w) && near(r.h, h);}@@ -132,3 +140,22 @@ TEST(shell_camera_notch_inset) {CHECK(g.rightTray.y == plain.rightTray.y + 37.0f);CHECK(computeShell(l, 1728, 1117, 1.0f, 5000.0f).notchBand.h <= 1117.0f * 0.25f); // never eats the window}++TEST(shell_right_shelf_undo_redo) {+ // #43: Undo and Redo top the right shelf; a layout stored before them (version < 3) gets them on load, once.+ const UiLayout l = standardLayout();+ CHECK(l.rightShelf.size() > 3 && l.rightShelf[0] == "edit.undo" && l.rightShelf[1] == "edit.redo");+ Json old = toJson(l);+ old.set("version", 2.0);+ old.set("rightShelf", shelfJson({"view.frame", "view.mask"}));+ UiLayout back;+ std::string err;+ CHECK(fromJson(old, back, err));+ CHECK(back.rightShelf.size() == 5 && back.rightShelf[0] == "edit.undo" && back.rightShelf[1] == "edit.redo" &&+ back.rightShelf[3] == "view.frame");+ // A current layout the user took them out of stays without them.+ Json now = toJson(l);+ now.set("rightShelf", shelfJson({"view.frame"}));+ CHECK(fromJson(now, back, err));+ CHECK(back.rightShelf.size() == 1);+}