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
Interface looks (work in progress): Forge Terminal, Phosphor and Blueprint with the SculptForge layout
islandmed060979398067
diff --git a/CMakeLists.txt b/CMakeLists.txtindex 1c81ba63..90323441 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -248,6 +248,8 @@ if(SCULPTFORGE_BUILD_APP)fontRegular ${CMAKE_CURRENT_SOURCE_DIR}/assets/fonts/Inter-Regular.ttffontSemiBold ${CMAKE_CURRENT_SOURCE_DIR}/assets/fonts/Inter-SemiBold.ttffontLucide ${CMAKE_CURRENT_SOURCE_DIR}/assets/fonts/lucide.ttf+ fontMono ${CMAKE_CURRENT_SOURCE_DIR}/assets/fonts/JetBrainsMono-Regular.ttf # the looks (Preferences > Interface > Look)+ fontMonoBold ${CMAKE_CURRENT_SOURCE_DIR}/assets/fonts/JetBrainsMono-SemiBold.ttfappIcon ${CMAKE_CURRENT_SOURCE_DIR}/assets/branding/sculptforge-256.pngsupporters ${CMAKE_CURRENT_SOURCE_DIR}/docs/supporters.txt # Help > About (never empty: it starts with comments)supportCard ${CMAKE_CURRENT_SOURCE_DIR}/assets/branding/support-card.jpg) # the support card's picture (decoded only when it shows)@@ -273,6 +275,7 @@ if(SCULPTFORGE_BUILD_APP)src/app/ShellGeometry.cppsrc/app/Palettes.cppsrc/app/Theme.cpp+ src/app/LookSchemes.cppsrc/app/I18n.cppsrc/app/I18nSpanish.cppsrc/app/CommandPalette.cpp@@ -516,7 +519,7 @@ if(SCULPTFORGE_BUILD_TESTS)# tests/test_main.cpp plus every tests/test_*.cpp (add a file to add tests; see tests/TestHarness.h).file(GLOB SCULPTFORGE_TEST_SOURCES CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_*.cpp)add_executable(sculptforge_tests ${SCULPTFORGE_TEST_SOURCES} src/cli/McpServer.cpp src/app/AssetLibrary.cpp- src/app/UiLayout.cpp src/app/ShellGeometry.cpp src/app/I18n.cpp src/app/I18nSpanish.cpp src/render/Camera.cpp+ src/app/UiLayout.cpp src/app/ShellGeometry.cpp src/app/LookSchemes.cpp src/app/I18n.cpp src/app/I18nSpanish.cpp src/render/Camera.cppsrc/render/Clusters.cpp src/render/Ghost.cpp)target_include_directories(sculptforge_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tests)target_compile_definitions(sculptforge_tests PRIVATE SF_TEST_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/tests/data")diff --git a/assets/fonts/JetBrainsMono-OFL.txt b/assets/fonts/JetBrainsMono-OFL.txtnew file mode 100644index 00000000..8bee4148--- /dev/null+++ b/assets/fonts/JetBrainsMono-OFL.txt@@ -0,0 +1,93 @@+Copyright 2020 The JetBrains Mono Project Authors (https://github.com/JetBrains/JetBrainsMono)++This Font Software is licensed under the SIL Open Font License, Version 1.1.+This license is copied below, and is also available with a FAQ at:+https://scripts.sil.org/OFL+++-----------------------------------------------------------+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007+-----------------------------------------------------------++PREAMBLE+The goals of the Open Font License (OFL) are to stimulate worldwide+development of collaborative font projects, to support the font creation+efforts of academic and linguistic communities, and to provide a free and+open framework in which fonts may be shared and improved in partnership+with others.++The OFL allows the licensed fonts to be used, studied, modified and+redistributed freely as long as they are not sold by themselves. The+fonts, including any derivative works, can be bundled, embedded,+redistributed and/or sold with any software provided that any reserved+names are not used by derivative works. The fonts and derivatives,+however, cannot be released under any other type of license. The+requirement for fonts to remain under this license does not apply+to any document created using the fonts or their derivatives.++DEFINITIONS+"Font Software" refers to the set of files released by the Copyright+Holder(s) under this license and clearly marked as such. This may+include source files, build scripts and documentation.++"Reserved Font Name" refers to any names specified as such after the+copyright statement(s).++"Original Version" refers to the collection of Font Software components as+distributed by the Copyright Holder(s).++"Modified Version" refers to any derivative made by adding to, deleting,+or substituting -- in part or in whole -- any of the components of the+Original Version, by changing formats or by porting the Font Software to a+new environment.++"Author" refers to any designer, engineer, programmer, technical+writer or other person who contributed to the Font Software.++PERMISSION & CONDITIONS+Permission is hereby granted, free of charge, to any person obtaining+a copy of the Font Software, to use, study, copy, merge, embed, modify,+redistribute, and sell modified and unmodified copies of the Font+Software, subject to the following conditions:++1) Neither the Font Software nor any of its individual components,+in Original or Modified Versions, may be sold by itself.++2) Original or Modified Versions of the Font Software may be bundled,+redistributed and/or sold with any software, provided that each copy+contains the above copyright notice and this license. These can be+included either as stand-alone text files, human-readable headers or+in the appropriate machine-readable metadata fields within text or+binary files as long as those fields can be easily viewed by the user.++3) No Modified Version of the Font Software may use the Reserved Font+Name(s) unless explicit written permission is granted by the corresponding+Copyright Holder. This restriction only applies to the primary font name as+presented to the users.++4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font+Software shall not be used to promote, endorse or advertise any+Modified Version, except to acknowledge the contribution(s) of the+Copyright Holder(s) and the Author(s) or with their explicit written+permission.++5) The Font Software, modified or unmodified, in part or in whole,+must be distributed entirely under this license, and must not be+distributed under any other license. The requirement for fonts to+remain under this license does not apply to any document created+using the Font Software.++TERMINATION+This license becomes null and void if any of the above conditions are+not met.++DISCLAIMER+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM+OTHER DEALINGS IN THE FONT SOFTWARE.diff --git a/assets/fonts/JetBrainsMono-Regular.ttf b/assets/fonts/JetBrainsMono-Regular.ttfnew file mode 100644index 00000000..dff66cc5Binary files /dev/null and b/assets/fonts/JetBrainsMono-Regular.ttf differdiff --git a/assets/fonts/JetBrainsMono-SemiBold.ttf b/assets/fonts/JetBrainsMono-SemiBold.ttfnew file mode 100644index 00000000..a70e69bdBinary files /dev/null and b/assets/fonts/JetBrainsMono-SemiBold.ttf differdiff --git a/src/app/App.cpp b/src/app/App.cppindex 37716167..ba83367c 100644--- a/src/app/App.cpp+++ b/src/app/App.cpp@@ -56,6 +56,10 @@ extern const unsigned char fontLucide[];extern const unsigned long long fontLucide_size;extern const unsigned char fontSemiBold[];extern const unsigned long long fontSemiBold_size;+extern const unsigned char fontMono[];+extern const unsigned long long fontMono_size;+extern const unsigned char fontMonoBold[];+extern const unsigned long long fontMonoBold_size;extern const unsigned char appIcon[];extern const unsigned long long appIcon_size;} // namespace assets@@ -209,8 +213,8 @@ bool App::init(const AppOptions& options) {ImFontConfig fontConfig;fontConfig.FontDataOwnedByAtlas = false;fontConfig.OversampleH = 2;- io.Fonts->AddFontFromMemoryTTF(const_cast<unsigned char*>(assets::fontRegular), int(assets::fontRegular_size),- 15.0f * scale, &fontConfig);+ fontRegular_ = io.Fonts->AddFontFromMemoryTTF(const_cast<unsigned char*>(assets::fontRegular), int(assets::fontRegular_size),+ 15.0f * scale, &fontConfig);// Lucide icons (ISC/MIT) merged into the UI font, so ICON_LC_* strings work in any label.{static const ImWchar kIconRanges[] = {ICON_MIN_LC, ICON_MAX_LC, 0};@@ -251,6 +255,30 @@ bool App::init(const AppOptions& options) {fontIcons_ = io.Fonts->AddFontFromMemoryTTF(const_cast<unsigned char*>(assets::fontLucide), int(assets::fontLucide_size),20.0f * scale, &big, kIconRanges);}+ { // JetBrains Mono (SIL OFL) for the looks (Preferences > Interface > Look), with the icons and box drawing.+ static const ImWchar kMonoRanges[] = {0x0020, 0x00FF, 0x2010, 0x2027, 0x2190, 0x21FF, 0x2500, 0x259F, 0x25A0, 0x25FF, 0};+ static const ImWchar kIconRanges[] = {ICON_MIN_LC, ICON_MAX_LC, 0};+ auto addMono = [&](const unsigned char* data, unsigned long long size, float px) {+ ImFont* f = io.Fonts->AddFontFromMemoryTTF(const_cast<unsigned char*>(data), int(size), px * scale, &fontConfig, kMonoRanges);+ ImFontConfig icons;+ icons.MergeMode = true;+ icons.PixelSnapH = true;+ icons.FontDataOwnedByAtlas = false;+ icons.GlyphMinAdvanceX = px * scale;+ icons.GlyphOffset = ImVec2(0, px * 0.13f * scale);+ io.Fonts->AddFontFromMemoryTTF(const_cast<unsigned char*>(assets::fontLucide), int(assets::fontLucide_size), px * scale,+ &icons, kIconRanges);+ return f;+ };+ fontMono_ = addMono(assets::fontMono, assets::fontMono_size, 15.0f);+ fontMonoSmall_ = addMono(assets::fontMono, assets::fontMono_size, 12.0f);+ fontMonoTiny_ = addMono(assets::fontMono, assets::fontMono_size, 10.5f);+ fontMonoBold_ = addMono(assets::fontMonoBold, assets::fontMonoBold_size, 15.0f);+ fontInterSmall_ = fontSmall_;+ fontInterTiny_ = fontTiny_;+ fontInterBold_ = fontBold_;+ theme::fonts = {fontMono_, fontMonoSmall_, fontMonoBold_};+ }{ // The support card's display sizes (PanelSupportCard.cpp): Latin only, so the atlas grows by a few glyphs.static const ImWchar kCardRanges[] = {0x0020, 0x00FF, 0x2014, 0x2014, 0x2019, 0x2019, 0x2026, 0x2026, 0};fontCardTitle_ = io.Fonts->AddFontFromMemoryTTF(const_cast<unsigned char*>(assets::fontSemiBold),@@ -272,6 +300,7 @@ bool App::init(const AppOptions& options) {ImGui::GetCurrentContext()->TestEngineHookItems = true; // lets the demo find buttons by labelio.IniFilename = nullptr; // fixed, reproducible layout}+ applyLook(); // Preferences > Interface > Look (after the fonts it may switch to)ImGui_ImplSDL3_InitForOpenGL(window_, glContext_);ImGui_ImplOpenGL3_Init("#version 330 core");diff --git a/src/app/App.h b/src/app/App.hindex a1b71574..203c189b 100644--- a/src/app/App.h+++ b/src/app/App.h@@ -1138,6 +1138,9 @@ public:// The part of the window the 3D view uses (logical px); the whole window while the UI is hidden.CanvasRect canvasRect() const;ShellGeometry shellGeometry() const; // every shell region for the current window (console rect, trays...)+ // Preferences > Interface > Look: applies uiPrefs_.look (colours, style, fonts, the viewport background).+ void applyLook();+ void drawLookSection(); // Preferences > Interface > Look (Config.cpp)ImFont* smallFont() const { return fontSmall_; } // 12 px captions (shelf labels, tiles)ImFont* boldFont() const { return fontBold_; } // SemiBold 15 (help titles)@@ -1150,6 +1153,18 @@ private:void drawShell();void drawTitleStrip(const ShellGeometry& g);void drawPaletteBar(const ShellGeometry& g);+ // The SculptForge layout (Preferences > Interface > Look): the status bar with the task menus, and a task menu's+ // drop-down (its palettes as sections). Old palette ids keep working: a palette opens in its menu.+ void drawStatusBar(const ShellGeometry& g);+ void drawTaskMenu();+ void drawLookChrome(); // a look's gaps, tile borders and effects (Shell.cpp)+ ShellMetrics shellMetrics() const;+ bool sculptForgeLayout() const { return uiPrefs_.shellLayout == 1; }+ void setShellLayout(int layout); // swaps the shelves to that layout's standard ones+ bool lookDirty_ = false; // uiPrefs_.look or the layout changed: applied at the start of the next shell+ CanvasRect focusRect_; // the tile under the pointer (tiled looks highlight its border)+ float menuX_ = 0.0f; // where the open task menu drops from+ 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);bool shelfItemShown(const std::string& item) const;@@ -1237,6 +1252,9 @@ private:void pollAlphaFile();ShellGeometry shell_; // this frame's regions (drawShell)ImFont* fontSmall_ = nullptr, *fontTiny_ = nullptr, *fontIcons_ = nullptr, *fontBold_ = nullptr;+ // JetBrains Mono (the looks' monospace) and the Inter fonts it stands in for while a look uses it.+ ImFont* fontRegular_ = nullptr, *fontMono_ = nullptr, *fontMonoSmall_ = nullptr, *fontMonoTiny_ = nullptr, *fontMonoBold_ = nullptr;+ ImFont* fontInterSmall_ = nullptr, *fontInterTiny_ = nullptr, *fontInterBold_ = nullptr;ImFont* fontCardTitle_ = nullptr, *fontCardHead_ = nullptr, *fontCardBody_ = nullptr; // the support card (Latin only)std::string dropdown_; // palette open as a drop-down ("" = none)float dropdownX_ = 0.0f;diff --git a/src/app/CommandPalette.cpp b/src/app/CommandPalette.cppindex ad84e4c1..e68c5531 100644--- a/src/app/CommandPalette.cpp+++ b/src/app/CommandPalette.cpp@@ -1,5 +1,6 @@// SculptForge - open source digital sculpting// SPDX-License-Identifier: GPL-3.0-or-later+#include "app/Theme.h"#include "app/CommandPalette.h"#include "app/App.h"@@ -285,9 +286,9 @@ void CommandPalette::draw(App& app, const CanvasRect& area) {if (ImGui::GetCurrentContext()->LogEnabled) ImGui::LogText("\n%s %s %s", trAction(a.id, a.label), trPath(a.palette).c_str(), chord.c_str());rows->ChannelsSetCurrent(0);if (r == selected_)- rows->AddRectFilled(p, ImVec2(p.x + w, p.y + rowH), IM_COL32(0xf0, 0x88, 0x2e, 0x30), 4.0f * s);+ rows->AddRectFilled(p, ImVec2(p.x + w, p.y + rowH), IM_COL32(0xf0, 0x88, 0x2e, 0x30), theme::rounding(4.0f * s));else if (hovered)- rows->AddRectFilled(p, ImVec2(p.x + w, p.y + rowH), IM_COL32(0xff, 0xff, 0xff, 0x0a), 4.0f * s);+ rows->AddRectFilled(p, ImVec2(p.x + w, p.y + rowH), IM_COL32(0xff, 0xff, 0xff, 0x0a), theme::rounding(4.0f * s));}}rows->ChannelsMerge();diff --git a/src/app/Config.cpp b/src/app/Config.cppindex b1b75a50..b7355c01 100644--- a/src/app/Config.cpp+++ b/src/app/Config.cpp@@ -9,6 +9,8 @@#include "app/App.h"#include "app/CrashLog.h"+#include "app/LookSchemes.h"+#include "app/Palettes.h"#include "app/Ui.h"#include "app/I18n.h"#include "core/Bake.h"@@ -65,6 +67,16 @@ Json toJson(const UiPrefs& p) {j.set("timelinePosition", std::string(p.timelineTop ? "top" : "bottom"));j.set("showAxes", p.showAxes);j.set("alphabeticalPalettes", p.alphabeticalPalettes);+ {+ Json look = Json::object();+ look.set("name", std::string(looks::lookKey(looks::LookId(p.look.look))));+ look.set("scheme", p.look.scheme);+ look.set("matchOmarchy", p.look.matchOmarchy);+ look.set("phosphor", std::string(p.look.amber ? "amber" : "green"));+ look.set("effects", p.look.effects);+ j.set("look", std::move(look));+ }+ j.set("layout", std::string(p.shellLayout == 1 ? "sculptforge" : "zbrush"));j.set("language", p.language);j.set("tablet", toJson(p.tablet));j.set("spaceMouse", toJson(p.spaceMouse));@@ -117,6 +129,14 @@ void fromJson(const Json& j, UiPrefs& p) {if (j["timelinePosition"].isString()) p.timelineTop = j["timelinePosition"].asString() != "bottom";p.showAxes = j["showAxes"].asBool(p.showAxes);p.alphabeticalPalettes = j["alphabeticalPalettes"].asBool(p.alphabeticalPalettes);+ if (const Json& look = j["look"]; look.isObject()) {+ if (look["name"].isString()) p.look.look = int(looks::lookFromKey(look["name"].asString()));+ if (look["scheme"].isString() && looks::findScheme(look["scheme"].asString())) p.look.scheme = look["scheme"].asString();+ p.look.matchOmarchy = look["matchOmarchy"].asBool(p.look.matchOmarchy);+ if (look["phosphor"].isString()) p.look.amber = look["phosphor"].asString() == "amber";+ p.look.effects = look["effects"].asBool(p.look.effects);+ }+ if (j["layout"].isString()) p.shellLayout = j["layout"].asString() == "sculptforge" ? 1 : 0;if (j["language"].isString()) p.language = languageCode(languageFromCode(j["language"].asString()));fromJson(j["tablet"], p.tablet);fromJson(j["spaceMouse"], p.spaceMouse);@@ -231,7 +251,7 @@ void App::initUiConfig(bool deterministic) {configDir_ = pref;SDL_free(pref);}- layout_ = standardLayout();+ layout_ = standardLayout(uiPrefs_.shellLayout);if (deterministic) return; // tests, renders and recordings always use the standard layoutstd::string err;if (fileExists(uiConfigPath()) && !readUiConfig(uiConfigPath(), err)) SDL_Log("%s", err.c_str());@@ -750,7 +770,7 @@ void App::storeConfig() {void App::restoreStandardUi() {const bool customize = layout_.customize;- layout_ = standardLayout();+ layout_ = standardLayout(uiPrefs_.shellLayout);layout_.customize = customize;actions_.clearOverrides();resetRadialMenus();@@ -1074,6 +1094,7 @@ void drawConfigSection(App& app) {void drawInterfaceSection(App& app) {UiPrefs& p = app.uiPrefs();+ app.drawLookSection();// Language (#44): each name in its own language, never translated, so it can be found in either.ImGui::AlignTextToFramePadding();ImGui::TextUnformatted(tr("Language"));@@ -1264,4 +1285,131 @@ void drawLightBoxSection(App& app) {} // namespace config++// Preferences > Interface > Look: four looks as swatch cards, the look's own options, and the layout.+void App::drawLookSection() {+ theme::LookSettings& l = uiPrefs_.look;+ const float s = uiScale_;+ tray::GroupLabel(*this, "Look");+ const float spacing = ImGui::GetStyle().ItemSpacing.x;+ const float cardW = std::floor((ImGui::GetContentRegionAvail().x - spacing) * 0.5f), cardH = 46.0f * s;+ for (int i = 0; i < int(looks::LookId::Count); ++i) {+ const looks::LookId id = looks::LookId(i);+ if (i % 2) ImGui::SameLine();+ looks::Palette pal;+ if (id == looks::LookId::ForgeTerminal) {+ const looks::SchemeInfo* sc = looks::findScheme(l.scheme);+ int n = 0;+ pal = (sc ? sc : looks::schemes(n))->palette;+ } else if (id == looks::LookId::Phosphor) {+ pal = looks::phosphorPalette(l.amber);+ } else if (id == looks::LookId::Blueprint) {+ pal = looks::blueprintPalette();+ } else {+ pal = {0x111113, 0x1b1b1d, 0x222225, 0x2b2b2f, 0x37373c, 0x4e4e55, 0x8c8c90, 0xb4b4b9, 0xd8d8d8, 0xf2f2f2, 0xf0882e,+ 0xf0882e, 0xe5604a, 0x9ece6a, 0xe0af68, false};+ }+ const std::string label = std::string(looks::lookName(id)) + "##look." + looks::lookKey(id);+ const bool clicked = ImGui::InvisibleButton(label.c_str(), ImVec2(cardW, cardH));+ const bool hovered = ImGui::IsItemHovered(), current = l.look == i;+ const ImVec2 a = ImGui::GetItemRectMin(), b = ImGui::GetItemRectMax();+ ImDrawList* dl = ImGui::GetWindowDrawList();+ auto col = [](unsigned hex) { return theme::u32(theme::rgb(hex)); };+ // A miniature of the look: its wallpaper, a bar with its accent, two tiles, its name in its text colour.+ dl->AddRectFilled(a, b, col(pal.crust));+ const float g = 3.0f * s;+ dl->AddRectFilled(ImVec2(a.x + g, a.y + g), ImVec2(b.x - g, a.y + g + 8.0f * s), col(pal.mantle));+ dl->AddRectFilled(ImVec2(a.x + g + 2.0f * s, a.y + g + 2.0f * s), ImVec2(a.x + g + 16.0f * s, a.y + g + 6.0f * s), col(pal.accent));+ dl->AddRectFilled(ImVec2(a.x + g, a.y + 2.0f * g + 8.0f * s), ImVec2(b.x - g - 30.0f * s, b.y - g), col(pal.base));+ dl->AddRectFilled(ImVec2(b.x - g - 26.0f * s, a.y + 2.0f * g + 8.0f * s), ImVec2(b.x - g, b.y - g), col(pal.base));+ dl->AddRectFilled(ImVec2(b.x - g - 22.0f * s, b.y - g - 8.0f * s), ImVec2(b.x - g - 4.0f * s, b.y - g - 4.0f * s), col(pal.accent2));+ ImFont* f = i == int(looks::LookId::Classic) ? fontInterSmall_ : fontMonoSmall_;+ if (!f) f = ImGui::GetFont();+ dl->AddText(f, f->FontSize, ImVec2(a.x + g + 6.0f * s, b.y - g - f->FontSize - 3.0f * s), col(pal.text), looks::lookName(id));+ dl->AddRect(a, b, theme::u32(current ? theme::accent : hovered ? theme::textDim : theme::tileBorder), 0.0f, 0,+ current ? 2.0f * s : 1.0f * s);+ ImGui::LogText("%s", looks::lookName(id));+ ui::HelpText(looks::lookName(id), nullptr,+ i == 0 ? "The original dark grey look with the orange accent."+ : i == 1 ? "Keyboard-first tiles with gaps and thin borders, monospace labels, a status bar, and the colours "+ "of a well-known terminal theme (or your Omarchy theme)."+ : i == 2 ? "A phosphor screen: green or amber on black, monospace, ASCII rules; optional scanlines on the interface."+ : "Engineering paper: deep blue, cyan and white line work, grid headers, technical numbers.",+ "Preferences > Interface > Look");+ if (clicked && !current) {+ l.look = i;+ if (i != 0) setShellLayout(1);+ lookDirty_ = true;+ }+ }+ if (l.look == int(looks::LookId::ForgeTerminal)) {+ int n = 0;+ const looks::SchemeInfo* list = looks::schemes(n);+ const looks::SchemeInfo* cur = looks::findScheme(l.scheme);+ ImGui::BeginDisabled(l.matchOmarchy);+ ImGui::SetNextItemWidth(-FLT_MIN);+ if (ImGui::BeginCombo("##look_scheme", (std::string(tr("Colours:")) + " " + (cur ? cur->name : list[0].name)).c_str())) {+ for (int i = 0; i < n; ++i) {+ const std::string item = std::string(list[i].name) + "##scheme." + list[i].key;+ if (ImGui::Selectable(item.c_str(), cur == &list[i])) {+ l.scheme = list[i].key;+ lookDirty_ = true;+ }+ // Its background and accent as two dots at the right.+ const ImVec2 b = ImGui::GetItemRectMax();+ const float r = 4.0f * s, cy = (ImGui::GetItemRectMin().y + b.y) * 0.5f;+ ImGui::GetWindowDrawList()->AddCircleFilled(ImVec2(b.x - 22.0f * s, cy), r, theme::u32(theme::rgb(list[i].palette.base)));+ ImGui::GetWindowDrawList()->AddCircleFilled(ImVec2(b.x - 10.0f * s, cy), r, theme::u32(theme::rgb(list[i].palette.accent)));+ }+ ImGui::EndCombo();+ }+ ImGui::EndDisabled();+ ui::HelpText("Colours", nullptr, "Forge Terminal's colour scheme, from well-known open-source terminal themes.",+ "Preferences > Interface > Look");+ const bool omarchy = !looks::omarchyThemeDir().empty();+ ImGui::BeginDisabled(!omarchy && !l.matchOmarchy);+ if (ui::Checkbox("Match my Omarchy theme##look.omarchy", &l.matchOmarchy)) lookDirty_ = true;+ ImGui::EndDisabled();+ ui::HelpText("Match my Omarchy theme", nullptr,+ omarchy ? "Use the colours of your current Omarchy theme (read from its theme folder; SculptForge never "+ "changes it). After switching themes in Omarchy, toggle this to pick up the new colours."+ : "Omarchy (a Linux setup) wasn't found on this computer.",+ "Preferences > Interface > Look");+ } else if (l.look == int(looks::LookId::Phosphor)) {+ if (ImGui::RadioButton(tr("Green##phosphor.green"), !l.amber)) {+ l.amber = false;+ lookDirty_ = true;+ }+ ImGui::SameLine();+ if (ImGui::RadioButton(tr("Amber##phosphor.amber"), l.amber)) {+ l.amber = true;+ lookDirty_ = true;+ }+ ImGui::SameLine();+ if (ui::Checkbox("Scanlines & glow##look.effects", &l.effects)) lookDirty_ = true;+ ui::HelpText("Scanlines & glow", nullptr,+ "Faint scanlines and a glow around the focused panel, on the interface only (never on the 3D view). Off by default.",+ "Preferences > Interface > Look");+ }+ ImGui::AlignTextToFramePadding();+ ImGui::TextUnformatted(tr("Layout"));+ ImGui::SameLine();+ if (ImGui::RadioButton(tr("SculptForge##layout.sculptforge"), uiPrefs_.shellLayout == 1)) {+ setShellLayout(1);+ lookDirty_ = true;+ }+ ui::HelpText("SculptForge layout", nullptr,+ "Menus by task (File, Edit, Sculpt, Paint, Mesh, View, Render, Help), a status bar and a one-row tool shelf. "+ "Every palette is a section of one menu, and F3 finds them all.",+ "Preferences > Interface > Look");+ ImGui::SameLine();+ if (ImGui::RadioButton(tr("ZBrush-style##layout.zbrush"), uiPrefs_.shellLayout == 0)) {+ setShellLayout(0);+ lookDirty_ = true;+ }+ ui::HelpText("ZBrush-style layout", nullptr, "The alphabetical palette bar and the two-row top shelf.",+ "Preferences > Interface > Look");+ tray::GroupLabel(*this, "Interface");+}+} // namespace sfdiff --git a/src/app/Config.h b/src/app/Config.hindex 701f6244..adb06e32 100644--- a/src/app/Config.h+++ b/src/app/Config.h@@ -8,6 +8,7 @@// Load UI (Ctrl+L) share a layout as a file.#pragma once+#include "app/Theme.h"#include "core/Json.h"#include "core/SpaceMouse.h"#include "core/Tablet.h"@@ -58,6 +59,11 @@ struct UiPrefs {// Preferences > Interface > Timeline position (#63): the Sculpt Timeline strip along the top of the viewport// (true, the default: clear of the brush shelf below it) or its bottom.bool timelineTop = true;+ // Preferences > Interface > Look: the colours and style of the interface (Theme.h; Classic is the default), and+ // the shell's layout: 0 the ZBrush-style layout (the alphabetical palette bar, two-row top shelf), 1 the+ // SculptForge layout (task menus File, Edit, Sculpt, Paint, Mesh, View, Render, Help, a status bar, one-row shelf).+ theme::LookSettings look;+ int shellLayout = 0;TabletSettings tablet; // Preferences > Tablet: pressure curve, eraser, pen buttonsSpaceMouseSettings spaceMouse; // Preferences > Input > SpaceMouse// Preferences > Performance (PanelPerformance.cpp).diff --git a/src/app/I18nSpanish.cpp b/src/app/I18nSpanish.cppindex fba977c2..32b65b15 100644--- a/src/app/I18nSpanish.cpp+++ b/src/app/I18nSpanish.cpp@@ -39,6 +39,22 @@ constexpr Entry kSpanish[] = {{"Stroke", "Trazo"},{"Tool", "Herramienta"},{"Transform", "Transformar"},+ // The SculptForge layout's task menus and their sections (Palettes.cpp taskMenus), Preferences > Interface > Look.+ {"Mesh", "Malla"},+ {"View", "Vista"},+ {"Draw & Tablet", "Dibujo y tableta"},+ {"Symmetry & Gizmo", "Simetría y gizmo"},+ {"Vertex Paint & Color", "Pintura de vértices y color"},+ {"Parts & Geometry", "Partes y geometría"},+ {"Materials", "Materiales"},+ {"Gaussian Splats", "Splats gaussianos"},+ {"Look", "Aspecto"},+ {"Colours:", "Colores:"},+ {"Match my Omarchy theme", "Usar mi tema de Omarchy"},+ {"Green", "Verde"},+ {"Amber", "Ámbar"},+ {"Scanlines & glow", "Líneas de barrido y brillo"},+ {"ZBrush-style", "Estilo ZBrush"},{"AI brush provider", "Proveedor del pincel IA"},{"Autosave", "Autoguardado"},{"Bake", "Bake"},diff --git a/src/app/LightBox.cpp b/src/app/LightBox.cppindex 34cf03b0..0f234bba 100644--- a/src/app/LightBox.cpp+++ b/src/app/LightBox.cpp@@ -1,5 +1,6 @@// SculptForge - open source digital sculpting// SPDX-License-Identifier: GPL-3.0-or-later+#include "app/Theme.h"#include "app/LightBox.h"#include "app/App.h"@@ -584,7 +585,7 @@ void LightBox::drawHeader(App& app, float width) {ImGui::PopStyleColor(4);if (on) {const ImVec2 a = ImGui::GetItemRectMin(), b = ImGui::GetItemRectMax();- dl->AddRectFilled(ImVec2(a.x + 4, b.y - 2), ImVec2(b.x - 4, b.y), kAccent, 1.0f);+ dl->AddRectFilled(ImVec2(a.x + 4, b.y - 2), ImVec2(b.x - 4, b.y), kAccent, theme::rounding(1.0f));}static const char* const tips[] = {"Your projects (.sfproj) and recently opened projects.",@@ -920,9 +921,9 @@ void LightBox::draw(App& app, const CanvasRect& canvas) {const float s = 64.0f * scale;ImDrawList* fg = ImGui::GetForegroundDrawList();const ImVec2 a(io.MousePos.x - s * 0.5f, io.MousePos.y - s * 0.5f), b(a.x + s, a.y + s);- fg->AddRectFilled(a, b, IM_COL32(42, 42, 46, 220), 4.0f);- if (tex) fg->AddImageRounded(tex, a, b, ImVec2(0, 0), ImVec2(1, 1), IM_COL32(255, 255, 255, 220), 4.0f);- fg->AddRect(a, b, kAccent, 4.0f, 0, 1.5f);+ fg->AddRectFilled(a, b, IM_COL32(42, 42, 46, 220), theme::rounding(4.0f));+ if (tex) fg->AddImageRounded(tex, a, b, ImVec2(0, 0), ImVec2(1, 1), IM_COL32(255, 255, 255, 220), theme::rounding(4.0f));+ fg->AddRect(a, b, kAccent, theme::rounding(4.0f), 0, 1.5f);}if (pressing_ && !ImGui::IsMouseDown(ImGuiMouseButton_Left)) {if (tileDrag_ && canvas.contains(io.MousePos.x, io.MousePos.y) && !ImGui::GetCurrentContext()->HoveredWindow)diff --git a/src/app/LookSchemes.cpp b/src/app/LookSchemes.cppnew file mode 100644index 00000000..54ecf3e8--- /dev/null+++ b/src/app/LookSchemes.cpp@@ -0,0 +1,225 @@+// SculptForge - open source digital sculpting+// SPDX-License-Identifier: GPL-3.0-or-later+#include "app/LookSchemes.h"++#include <cstdlib>+#include <filesystem>+#include <fstream>+#include <iterator>+#include <map>+#include <sstream>++namespace sf::looks {++namespace {++constexpr const char* kLookKeys[] = {"classic", "forge", "phosphor", "blueprint"};+constexpr const char* kLookNames[] = {"Classic", "Forge Terminal", "Phosphor", "Blueprint"};++// crust, mantle, base, surface0, surface1, surface2, overlay, subtext, text, bright, accent, accent2, red, green,+// yellow. Values from each scheme's published palette; crust and mantle are darkened from its background where the+// scheme has fewer background steps.+const SchemeInfo kSchemes[] = {+ {"tokyo_night", "Tokyo Night", "github.com/enkia/tokyo-night-vscode-theme", "MIT",+ {0x101118, 0x16161e, 0x1a1b26, 0x232535, 0x292e42, 0x414868, 0x6a73a0, 0xa9b1d6, 0xc0caf5, 0xdfe5ff, 0x7aa2f7,+ 0xbb9af7, 0xf7768e, 0x9ece6a, 0xe0af68, false}},+ {"catppuccin_mocha", "Catppuccin Mocha", "github.com/catppuccin/catppuccin", "MIT",+ {0x11111b, 0x181825, 0x1e1e2e, 0x313244, 0x45475a, 0x585b70, 0x7f849c, 0xbac2de, 0xcdd6f4, 0xeef1ff, 0xcba6f7,+ 0x89b4fa, 0xf38ba8, 0xa6e3a1, 0xf9e2af, false}},+ {"gruvbox_dark", "Gruvbox Dark", "github.com/morhetz/gruvbox", "MIT",+ {0x141617, 0x1d2021, 0x282828, 0x3c3836, 0x504945, 0x665c54, 0x928374, 0xbdae93, 0xebdbb2, 0xfbf1c7, 0xfabd2f,+ 0x8ec07c, 0xfb4934, 0xb8bb26, 0xfabd2f, false}},+ {"nord", "Nord", "github.com/nordtheme/nord", "MIT",+ {0x20242c, 0x272c36, 0x2e3440, 0x3b4252, 0x434c5e, 0x4c566a, 0x7b88a1, 0xd8dee9, 0xe5e9f0, 0xf4f6fa, 0x88c0d0,+ 0x81a1c1, 0xbf616a, 0xa3be8c, 0xebcb8b, false}},+ {"rose_pine", "Rosé Pine", "github.com/rose-pine/rose-pine-theme", "MIT",+ {0x0f0d16, 0x15131e, 0x191724, 0x1f1d2e, 0x26233a, 0x403d52, 0x6e6a86, 0x908caa, 0xe0def4, 0xf4f2ff, 0xebbcba,+ 0x9ccfd8, 0xeb6f92, 0x9ccfd8, 0xf6c177, false}},+ {"kanagawa", "Kanagawa", "github.com/rebelot/kanagawa.nvim", "MIT",+ {0x16161d, 0x1a1a22, 0x1f1f28, 0x2a2a37, 0x363646, 0x54546d, 0x727169, 0xc8c093, 0xdcd7ba, 0xf2eedb, 0x7fb4ca,+ 0xe6c384, 0xe46876, 0x98bb6c, 0xe6c384, false}},+ {"everforest", "Everforest", "github.com/sainnhe/everforest", "MIT",+ {0x1e2326, 0x232a2e, 0x2d353b, 0x343f44, 0x3d484d, 0x475258, 0x859289, 0x9da9a0, 0xd3c6aa, 0xede3cb, 0xa7c080,+ 0x83c092, 0xe67e80, 0xa7c080, 0xdbbc7f, false}},+};++unsigned mix(unsigned a, unsigned b, float t) {+ auto ch = [&](int shift) {+ const float x = float((a >> shift) & 0xff), y = float((b >> shift) & 0xff);+ return unsigned(x + (y - x) * t + 0.5f) & 0xff;+ };+ return (ch(16) << 16) | (ch(8) << 8) | ch(0);+}++float luminance(unsigned c) {+ return (0.2126f * float((c >> 16) & 0xff) + 0.7152f * float((c >> 8) & 0xff) + 0.0722f * float(c & 0xff)) / 255.0f;+}++std::string trim(std::string s) {+ const size_t a = s.find_first_not_of(" \t\r\n");+ if (a == std::string::npos) return {};+ const size_t b = s.find_last_not_of(" \t\r\n");+ return s.substr(a, b - a + 1);+}++// "section.key" -> "#rrggbb" for every `key = "#rrggbb"` (or '#rrggbb' or 0xrrggbb) line of a TOML file.+std::map<std::string, unsigned> tomlColours(const std::string& text) {+ std::map<std::string, unsigned> out;+ std::istringstream in(text);+ std::string line, section;+ while (std::getline(in, line)) {+ line = trim(line);+ if (line.empty() || line[0] == '#') continue;+ if (line.front() == '[' && line.back() == ']') {+ section = trim(line.substr(1, line.size() - 2));+ continue;+ }+ const size_t eq = line.find('=');+ if (eq == std::string::npos) continue;+ const std::string key = trim(line.substr(0, eq));+ std::string value = trim(line.substr(eq + 1));+ if (const size_t hash = value.find(" #"); hash != std::string::npos) value = trim(value.substr(0, hash)); // comment+ if (value.size() >= 2 && (value.front() == '"' || value.front() == '\'')) value = value.substr(1, value.size() - 2);+ if (value.rfind("0x", 0) == 0) value = value.substr(2);+ unsigned c = 0;+ if (parseHex(value, c)) out[section.empty() ? key : section + "." + key] = c;+ }+ return out;+}++std::string readFile(const std::filesystem::path& p) {+ std::ifstream f(p, std::ios::binary);+ if (!f) return {};+ return std::string(std::istreambuf_iterator<char>(f), std::istreambuf_iterator<char>());+}++} // namespace++const char* lookKey(LookId look) {+ const int i = int(look);+ return i >= 0 && i < int(LookId::Count) ? kLookKeys[i] : kLookKeys[0];+}++const char* lookName(LookId look) {+ const int i = int(look);+ return i >= 0 && i < int(LookId::Count) ? kLookNames[i] : kLookNames[0];+}++LookId lookFromKey(std::string_view key) {+ for (int i = 0; i < int(LookId::Count); ++i)+ if (key == kLookKeys[i]) return LookId(i);+ if (key == "forge_terminal") return LookId::ForgeTerminal;+ return LookId::Classic;+}++const SchemeInfo* schemes(int& count) {+ count = int(std::size(kSchemes));+ return kSchemes;+}++const SchemeInfo* findScheme(std::string_view key) {+ for (const SchemeInfo& s : kSchemes)+ if (key == s.key) return &s;+ return nullptr;+}++Palette phosphorPalette(bool amber) {+ // A P1 green or P3 amber phosphor on a near-black tube: every step is the phosphor colour at another brightness.+ if (amber)+ return {0x0a0602, 0x0f0a04, 0x140d05, 0x22170a, 0x30210e, 0x4a3314, 0x9a6a2c, 0xd39a48, 0xffb84d, 0xffe0a3,+ 0xffc35c, 0xffe0a3, 0xff6a4d, 0xffc35c, 0xffd27a, false};+ return {0x030805, 0x060d08, 0x08120b, 0x0f2216, 0x15311f, 0x1f4a2e, 0x3f9a5c, 0x63d685, 0x7cf7a0, 0xc8ffd8,+ 0x5dff8a, 0xc8ffd8, 0xff6b5d, 0x5dff8a, 0xd8ff6b, false};+}++Palette blueprintPalette() {+ // Cyanotype paper: deep Prussian blue, white and cyan line work.+ return {0x061833, 0x0a2142, 0x0c2750, 0x113463, 0x17427a, 0x2a5d9a, 0x6b93c4, 0xa9c4e6, 0xdbe8fa, 0xffffff,+ 0x6fe3ff, 0xffffff, 0xff7a85, 0x7dffc4, 0xffe27a, false};+}++bool parseHex(std::string_view text, unsigned& out) {+ if (!text.empty() && text.front() == '#') text.remove_prefix(1);+ if (text.size() == 8) text = text.substr(0, 6); // #rrggbbaa: drop the alpha+ if (text.size() != 6) return false;+ unsigned v = 0;+ for (char c : text) {+ v <<= 4;+ if (c >= '0' && c <= '9') v |= unsigned(c - '0');+ else if (c >= 'a' && c <= 'f') v |= unsigned(c - 'a' + 10);+ else if (c >= 'A' && c <= 'F') v |= unsigned(c - 'A' + 10);+ else return false;+ }+ out = v;+ return true;+}++bool paletteFromOmarchy(const std::string& colorsToml, const std::string& alacrittyToml, Palette& out) {+ const auto c = tomlColours(colorsToml);+ const auto a = tomlColours(alacrittyToml);+ auto pick = [&](std::initializer_list<const char*> keys, unsigned& v) {+ for (const char* k : keys) {+ if (auto it = c.find(k); it != c.end()) return v = it->second, true;+ if (auto it = a.find(k); it != a.end()) return v = it->second, true;+ }+ return false;+ };+ Palette p;+ if (!pick({"background", "colors.primary.background"}, p.base)) return false;+ if (!pick({"foreground", "colors.primary.foreground"}, p.text)) return false;+ p.light = luminance(p.base) > 0.5f; // (colors.toml's mode = "light" says the same)+ const unsigned toward = p.light ? 0xffffff : 0x000000; // "darker" backgrounds of a light theme get lighter+ if (!pick({"dark_background"}, p.mantle)) p.mantle = mix(p.base, toward, 0.18f);+ if (!pick({"darker_background"}, p.crust)) p.crust = mix(p.base, toward, 0.36f);+ if (!pick({"lighter_background"}, p.surface0)) p.surface0 = mix(p.base, p.text, 0.08f);+ if (!pick({"selection", "colors.selection.background"}, p.surface1)) p.surface1 = mix(p.base, p.text, 0.14f);+ if (!pick({"muted", "colors.bright.black"}, p.surface2)) p.surface2 = mix(p.base, p.text, 0.26f);+ if (!pick({"dark_foreground"}, p.overlay)) p.overlay = mix(p.base, p.text, 0.5f);+ p.subtext = mix(p.text, p.base, 0.2f);+ if (!pick({"bright_foreground", "light_foreground"}, p.bright)) p.bright = mix(p.text, p.light ? 0x000000 : 0xffffff, 0.3f);+ if (!pick({"accent", "colors.normal.blue", "blue"}, p.accent)) p.accent = mix(p.text, p.base, 0.1f);+ if (!pick({"magenta", "colors.normal.magenta"}, p.accent2)) p.accent2 = p.accent;+ if (!pick({"red", "colors.normal.red"}, p.red)) p.red = 0xe5604a;+ if (!pick({"green", "colors.normal.green"}, p.green)) p.green = 0x9ece6a;+ if (!pick({"yellow", "colors.normal.yellow"}, p.yellow)) p.yellow = 0xe0af68;+ // Themes whose accent is their foreground (Kanagawa's) would show the current tool no differently from text.+ if (p.accent == p.text) pick({"blue", "colors.normal.blue", "cyan"}, p.accent);+ out = p;+ return true;+}++std::string omarchyThemeDir() {+#if defined(__linux__)+ const char* home = std::getenv("HOME");+ if (!home || !*home) return {};+ std::error_code ec;+ for (const char* rel : {"/.config/omarchy/current/theme", "/.local/state/omarchy/current/theme"}) {+ const std::filesystem::path p = std::filesystem::path(home).concat(rel);+ if (std::filesystem::is_directory(p, ec)) return p.string();+ }+#endif+ return {};+}++bool readOmarchyTheme(Palette& out, std::string& name, std::string& error) {+ const std::string dir = omarchyThemeDir();+ if (dir.empty()) {+ error = "No Omarchy theme found (~/.config/omarchy/current/theme)";+ return false;+ }+ const std::filesystem::path d(dir);+ const std::string colors = readFile(d / "colors.toml"), alacritty = readFile(d / "alacritty.toml");+ if (!paletteFromOmarchy(colors, alacritty, out)) {+ error = "The Omarchy theme has no colours SculptForge can read (colors.toml or alacritty.toml)";+ return false;+ }+ name = trim(readFile(d.parent_path() / "theme.name"));+ if (name.empty()) {+ std::error_code ec;+ const auto target = std::filesystem::read_symlink(d, ec); // older Omarchy: a link to the theme's folder+ name = ec ? std::string("Omarchy") : target.filename().string();+ }+ return true;+}++} // namespace sf::looksdiff --git a/src/app/LookSchemes.h b/src/app/LookSchemes.hnew file mode 100644index 00000000..9657195e--- /dev/null+++ b/src/app/LookSchemes.h@@ -0,0 +1,62 @@+// SculptForge - open source digital sculpting+// SPDX-License-Identifier: GPL-3.0-or-later+//+// The interface looks (Preferences > Interface > Look) and their colour schemes, as plain data: no ImGui, so the+// scheme table and the Omarchy theme reader can be unit tested. Theme.cpp turns a Palette into the shell's colour+// tokens. The colour values of the open-source schemes are credited in THIRD_PARTY_NOTICES.md.+#pragma once++#include <string>+#include <string_view>++namespace sf::looks {++enum class LookId { Classic = 0, ForgeTerminal, Phosphor, Blueprint, Count };++const char* lookKey(LookId look); // "classic", "forge", "phosphor", "blueprint" (ui.json, the ui_look command)+const char* lookName(LookId look); // "Classic", "Forge Terminal", ...+LookId lookFromKey(std::string_view key); // Classic when unknown++// A colour scheme as twelve-odd 0xRRGGBB values, darkest to brightest, plus the accents. The names follow+// Catppuccin's roles, which most terminal themes map onto.+struct Palette {+ unsigned crust = 0, mantle = 0, base = 0; // gaps / wallpaper, bars and shelves, panels+ unsigned surface0 = 0, surface1 = 0, surface2 = 0; // headers and buttons, hover and selection, pressed / borders+ unsigned overlay = 0; // dim text, rules+ unsigned subtext = 0, text = 0, bright = 0; // secondary text, text, emphasised text+ unsigned accent = 0, accent2 = 0; // the current tool or mode, a second highlight+ unsigned red = 0, green = 0, yellow = 0;+ bool light = false;+};++struct SchemeInfo {+ const char* key; // "tokyo_night"+ const char* name; // "Tokyo Night"+ const char* source; // where the colours come from+ const char* license; // its licence (THIRD_PARTY_NOTICES.md)+ Palette palette;+};++// Forge Terminal's schemes, Tokyo Night first (the default).+const SchemeInfo* schemes(int& count);+const SchemeInfo* findScheme(std::string_view key); // nullptr when unknown++// Phosphor's two screens and Blueprint's paper.+Palette phosphorPalette(bool amber);+Palette blueprintPalette();++// "#7aa2f7" or "7aa2f7" -> 0x7aa2f7.+bool parseHex(std::string_view text, unsigned& out);++// An Omarchy theme's colours. `colorsToml` is its colors.toml (accent, background, foreground, ... = "#rrggbb");+// `alacrittyToml` its alacritty.toml, used for what colors.toml lacks (older themes have only that). Either may+// be empty. False when neither gives at least a background and a foreground.+bool paletteFromOmarchy(const std::string& colorsToml, const std::string& alacrittyToml, Palette& out);++// The current Omarchy theme folder: ~/.config/omarchy/current/theme or, on newer Omarchy, ~/.local/state/omarchy/+// current/theme; "" when neither exists (or not on Linux). Only ever read.+std::string omarchyThemeDir();+// Reads the current Omarchy theme (never writes anything). `name` gets its name when known.+bool readOmarchyTheme(Palette& out, std::string& name, std::string& error);++} // namespace sf::looksdiff --git a/src/app/Palettes.cpp b/src/app/Palettes.cppindex a173630a..a4194809 100644--- a/src/app/Palettes.cpp+++ b/src/app/Palettes.cpp@@ -60,15 +60,51 @@ const PaletteDef* findPalette(std::string_view id) {return nullptr;}+const TaskMenuDef* taskMenus(int& count) {+ // Every palette in exactly one menu (tests/ui/looks.sfui opens every section). View is how the model shows, Render how it+ // is shaded (Lit Sphere materials, PBR) and the Gaussian splats.+ static const TaskMenuDef kMenus[] = {+ {"file", "File", {"file", "script", nullptr}, {nullptr, nullptr}},+ {"edit", "Edit", {"edit", "preferences", nullptr}, {nullptr, nullptr}},+ {"sculpt", "Sculpt", {"brush", "draw", "stroke", "alpha", "transform", nullptr}, {nullptr, "Draw & Tablet", nullptr, nullptr, "Symmetry & Gizmo"}},+ {"paint", "Paint", {"color", nullptr}, {"Vertex Paint & Color"}},+ {"mesh", "Mesh", {"tool", "generate", nullptr}, {"Parts & Geometry", "Generate 3D"}},+ {"view", "View", {"render", nullptr}, {"Display"}},+ {"render", "Render", {"material", "splats", nullptr}, {"Materials", "Gaussian Splats"}},+ {"help", "Help", {"help", nullptr}, {nullptr}},+ };+ count = int(std::size(kMenus));+ return kMenus;+}++int taskMenuOf(std::string_view paletteId) {+ int count = 0;+ const TaskMenuDef* menus = taskMenus(count);+ for (int i = 0; i < count; ++i)+ for (int k = 0; k < 6 && menus[i].sections[k]; ++k)+ if (paletteId == menus[i].sections[k]) return i;+ return -1;+}+namespace {// The hairline under each sub-palette header: opaque, a clear step above panelBg so the closed list reads as rows.// Should become a theme token (Theme.h).-constexpr ImU32 kSectionRule = IM_COL32(54, 54, 60, 255);+ImU32 sectionRule() { return theme::look.id == 0 ? IM_COL32(54, 54, 60, 255) : theme::u32(theme::sectionRule); }constexpr float kSectionHeaderH = 22.0f; // sub-palette header height, unscaledconstexpr float kSectionInset = 8.0f; // header titles and section content start this far in, unscaled// Check marks in the palettes: the text colour, so a column of options doesn't read as a row of accents.-constexpr ImVec4 kCheckMark = theme::rgb(0xd8d8d8);+ImVec4 checkMark() { return theme::look.id == 0 ? theme::rgb(0xd8d8d8) : theme::text; }++// Phosphor's rules: a run of box-drawing lines from x0 to x1 on the text's centre line, in the current font.+void asciiRule(ImDrawList* dl, float x0, float x1, float y, ImU32 col) {+ ImFont* f = ImGui::GetFont();+ const float cw = f->CalcTextSizeA(f->FontSize, FLT_MAX, 0.0f, "\xe2\x94\x80").x;+ if (cw <= 0.0f || x1 - x0 < cw) return;+ std::string run;+ for (float x = x0; x + cw <= x1; x += cw) run += "\xe2\x94\x80";+ dl->AddText(ImVec2(std::floor(x0), std::floor(y)), col, run.c_str());+}// A row of equal-width action buttons filling the line.void actionRow(App& app, std::initializer_list<const char*> ids) {@@ -135,16 +171,32 @@ Section::~Section() {ImGui::Dummy(ImVec2(0, 4.0f * s));}-Style::Style() { ImGui::PushStyleColor(ImGuiCol_CheckMark, kCheckMark); }+Style::Style() { ImGui::PushStyleColor(ImGuiCol_CheckMark, checkMark()); }Style::~Style() { ImGui::PopStyleColor(); }void GroupLabel(const App& app, const char* text) {const float s = ImGui::GetFontSize() / 15.0f;ImGui::Dummy(ImVec2(0, 2.0f * s));+ if (theme::look.headers == theme::LookStyle::Headers::Ascii) { // "-- Extract -----------" in box-drawing lines+ if (app.smallFont()) ImGui::PushFont(app.smallFont());+ const ImVec2 p = ImGui::GetCursorScreenPos();+ const float w = ImGui::GetContentRegionAvail().x, h = ImGui::GetTextLineHeight();+ ImGui::Dummy(ImVec2(w, h + 2.0f * s));+ ImDrawList* dl = ImGui::GetWindowDrawList();+ const ImU32 rule = theme::u32(theme::textDim, 0.6f);+ const std::string label = std::string(" ") + tr(text) + " ";+ asciiRule(dl, p.x, p.x + 2.0f * ImGui::CalcTextSize("-").x, p.y, rule);+ const float lx = p.x + 2.0f * ImGui::CalcTextSize("-").x;+ dl->AddText(ImVec2(lx, p.y), theme::u32(theme::textDim), label.c_str());+ asciiRule(dl, lx + ImGui::CalcTextSize(label.c_str()).x, p.x + w, p.y, rule);+ ImGui::LogText("%s", tr(text));+ if (app.smallFont()) ImGui::PopFont();+ return;+ }if (app.smallFont()) ImGui::PushFont(app.smallFont());ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetStyleColorVec4(ImGuiCol_TextDisabled));- ImGui::PushStyleColor(ImGuiCol_Separator, ImGui::ColorConvertU32ToFloat4(kSectionRule));+ ImGui::PushStyleColor(ImGuiCol_Separator, ImGui::ColorConvertU32ToFloat4(sectionRule()));ImGui::PushStyleVar(ImGuiStyleVar_SeparatorTextPadding, ImVec2(0.0f, 2.0f * s));ImGui::PushStyleVar(ImGuiStyleVar_SeparatorTextAlign, ImVec2(0.0f, 0.5f));ImGui::SeparatorText(tr(text));@@ -181,10 +233,33 @@ bool App::subpalette(const char* id, const char* englishTitle) {// hovered or open, a hairline under it. The title lines up with the section's content (tray::Section). The accent// is kept for the current tool (docs/ui-design.md §10), so an open section shows by its fill and text only.ImDrawList* dl = ImGui::GetWindowDrawList();+ using Headers = theme::LookStyle::Headers;+ const Headers headers = theme::look.headers;+ if (headers == Headers::Ascii) { // "[+] Geometry" / "[-] Geometry", no fill but the hover+ if (hovered) dl->AddRectFilled(p, ImVec2(p.x + w, p.y + h), theme::u32(theme::headerHover, 0.6f));+ const float ty = std::floor(p.y + (h - ImGui::GetFontSize()) * 0.5f);+ dl->AddText(ImVec2(p.x + 2.0f * s, ty), theme::u32(isOpen ? theme::accent : theme::textDim), isOpen ? "[-]" : "[+]");+ dl->AddText(ImVec2(p.x + 2.0f * s + ImGui::CalcTextSize("[-] ").x, ty), theme::u32(isOpen || hovered ? theme::textBright : theme::text),+ title);+ ImGui::LogText("%s", title);+ ui::HelpText(title, nullptr,+ "Click to open or close. Opening one closes the others (Shift+click keeps them open; Preferences > "+ "Interface).",+ "Tool");+ } else {if (isOpen || hovered)dl->AddRectFilled(p, ImVec2(p.x + w, p.y + h), theme::u32(hovered ? theme::headerHover : theme::header, isOpen ? 0.9f : 0.6f),- 2.0f * s);- dl->AddLine(ImVec2(p.x, p.y + h - 0.5f * s), ImVec2(p.x + w, p.y + h - 0.5f * s), kSectionRule, 1.0f * s);+ theme::rounding(2.0f * s));+ if (headers == Headers::Grid) { // a dimension line: the hairline in the accent with ticks at both ends+ const float y = std::floor(p.y + h - 1.0f) + 0.5f;+ const ImU32 c = theme::u32(theme::accent, isOpen ? 0.55f : 0.3f);+ dl->AddLine(ImVec2(p.x, y), ImVec2(p.x + w, y), c, 1.0f);+ dl->AddLine(ImVec2(p.x + 0.5f, y - 4.0f * s), ImVec2(p.x + 0.5f, y + 0.5f), c, 1.0f);+ dl->AddLine(ImVec2(p.x + w - 0.5f, y - 4.0f * s), ImVec2(p.x + w - 0.5f, y + 0.5f), c, 1.0f);+ } else {+ dl->AddLine(ImVec2(p.x, p.y + h - 0.5f * s), ImVec2(p.x + w, p.y + h - 0.5f * s), sectionRule(), 1.0f * s);+ }+ if (isOpen && headers == Headers::Bar) dl->AddRectFilled(p, ImVec2(p.x + 2.0f * s, p.y + h), theme::u32(theme::accent));ImFont* font = ImGui::GetFont();const float chevronSize = ImGui::GetFontSize() * 0.8f;const char* chevron = isOpen ? ICON_LC_CHEVRON_DOWN : ICON_LC_CHEVRON_RIGHT;@@ -198,6 +273,7 @@ bool App::subpalette(const char* id, const char* englishTitle) {"Click to open or close. Opening one closes the others (Shift+click keeps them open; Preferences > ""Interface).","Tool");+ }if (clicked) {if (isOpen) {open.erase(std::remove(open.begin(), open.end(), id), open.end());diff --git a/src/app/PanelBrushes.cpp b/src/app/PanelBrushes.cppindex c7010957..e17e3d61 100644--- a/src/app/PanelBrushes.cpp+++ b/src/app/PanelBrushes.cpp@@ -3,6 +3,7 @@//// Brush options panel (stroke type, lazy mouse, spray, alpha) and the// stroke handling of the SnakeHook brush and the DragRect stroke.+#include "app/Theme.h"#include "app/App.h"#include "app/Ui.h"@@ -42,7 +43,7 @@ void App::drawAlphaSection() {const float s = uiScale_;auto preview = [](ImDrawList* dl, const BrushAlpha& a, ImVec2 p0, float size, int cells) {const float cell = size / float(cells);- dl->AddRectFilled(p0, ImVec2(p0.x + size, p0.y + size), IM_COL32(0, 0, 0, 255), 3.0f);+ dl->AddRectFilled(p0, ImVec2(p0.x + size, p0.y + size), IM_COL32(0, 0, 0, 255), theme::rounding(3.0f));for (int y = 0; y < cells; ++y)for (int x = 0; x < cells; ++x) {const float u = (float(x) + 0.5f) / float(cells) * 2.0f - 1.0f, v = 1.0f - (float(y) + 0.5f) / float(cells) * 2.0f;diff --git a/src/app/PanelSubTools.cpp b/src/app/PanelSubTools.cppindex 763900a0..81d0c9d0 100644--- a/src/app/PanelSubTools.cpp+++ b/src/app/PanelSubTools.cpp@@ -28,7 +28,8 @@ namespace {constexpr float kClickSlopPx = 4.0f; // movement that turns an Alt+click into a dragconstexpr int kListRows = 6; // the list scrolls beyond this many SubTools// The SubTool list's colours; should become theme tokens (Theme.h).-constexpr ImVec4 kListWell = theme::rgb(0x1c1c1f); // the recessed area behind the rows, a step below panelBg+// The recessed area behind the rows, a step below panelBg (the Classic look's #1c1c1f; other looks their shelf shade).+ImVec4 listWell() { return theme::look.id == 0 ? theme::rgb(0x1c1c1f) : theme::shellBg; }constexpr ImVec4 kRowSelected = theme::rgb(0xffffff, 0.09f); // the active row: lighter neutral, plus the accent barconstexpr ImVec4 kRowHover = theme::rgb(0xffffff, 0.11f);constexpr ImVec4 kRowPressed = theme::rgb(0xffffff, 0.14f);@@ -203,7 +204,7 @@ void App::drawSubToolsContents() {{const ImVec2 w0 = ImGui::GetCursorScreenPos();ImGui::GetWindowDrawList()->AddRectFilled(w0, ImVec2(w0.x + ImGui::GetContentRegionAvail().x, w0.y + listH),- ImGui::ColorConvertFloat4ToU32(kListWell), style.FrameRounding);+ ImGui::ColorConvertFloat4ToU32(listWell()), style.FrameRounding);}ImGui::PushStyleColor(ImGuiCol_Header, kRowSelected);ImGui::PushStyleColor(ImGuiCol_HeaderHovered, kRowHover);@@ -290,11 +291,11 @@ void App::drawSubToolsContents() {// The thumbnail, or a quiet placeholder until it's rendered (updateSubtoolThumbnails).ImDrawList* dl = ImGui::GetWindowDrawList();const ImVec2 t1(thumbAt.x + thumb, thumbAt.y + thumb);- dl->AddRectFilled(thumbAt, t1, ImGui::ColorConvertFloat4ToU32(kThumbWell), 3.0f * scale);+ dl->AddRectFilled(thumbAt, t1, ImGui::ColorConvertFloat4ToU32(kThumbWell), theme::rounding(3.0f * scale));const auto tex = subtoolThumbs_.find(s.id);if (tex != subtoolThumbs_.end() && tex->second)dl->AddImageRounded(ImTextureID(uintptr_t(tex->second)), thumbAt, t1, ImVec2(0, 0), ImVec2(1, 1),- IM_COL32(255, 255, 255, s.visible ? 255 : 110), 3.0f * scale);+ IM_COL32(255, 255, 255, s.visible ? 255 : 110), theme::rounding(3.0f * scale));elsedl->AddCircle(ImVec2(thumbAt.x + thumb * 0.5f, thumbAt.y + thumb * 0.5f), thumb * 0.28f,ImGui::GetColorU32(style.Colors[ImGuiCol_TextDisabled]), 0, 1.0f * scale);diff --git a/src/app/Pickers.cpp b/src/app/Pickers.cppindex 9315afd3..daeea1c0 100644--- a/src/app/Pickers.cpp+++ b/src/app/Pickers.cpp@@ -3,6 +3,7 @@//// Pop-up pickers (ZBrush's brush, stroke, alpha and material pop-ups), the// Draw Size / Strength sliders at the cursor, and the thumbnail tile.+#include "app/Theme.h"#include "app/Pickers.h"#include "app/App.h"@@ -27,15 +28,18 @@ namespace sf {namespace {-// Theme tokens (docs/ui-design.md section 10).-constexpr ImU32 kAccent = IM_COL32(240, 136, 46, 255);-constexpr ImU32 kTileBg = IM_COL32(42, 42, 46, 255);-constexpr ImU32 kTileHover = IM_COL32(54, 54, 59, 255);-constexpr ImU32 kTileBorder = IM_COL32(18, 18, 20, 255);-constexpr ImU32 kGlyph = IM_COL32(140, 140, 144, 255);-constexpr ImU32 kText = IM_COL32(216, 216, 216, 255);-constexpr ImU32 kTextDim = IM_COL32(140, 140, 144, 255);-constexpr ImU32 kPanelBg = IM_COL32(37, 37, 40, 252); // #252528, pop-ups+// Theme tokens (docs/ui-design.md section 10): the Classic look's values, or the current look's tokens.+ImU32 lookColor(ImU32 classic, const ImVec4& token, float alpha = 1.0f) {+ return theme::look.id == 0 ? classic : theme::u32(token, alpha);+}+ImU32 kAccent() { return lookColor(IM_COL32(240, 136, 46, 255), theme::accent); }+ImU32 kTileBg() { return lookColor(IM_COL32(42, 42, 46, 255), theme::tile); }+ImU32 kTileHover() { return lookColor(IM_COL32(54, 54, 59, 255), theme::headerHover); }+ImU32 kTileBorder() { return lookColor(IM_COL32(18, 18, 20, 255), theme::tileBorder); }+ImU32 kGlyph() { return lookColor(IM_COL32(140, 140, 144, 255), theme::textDim); }+ImU32 kText() { return lookColor(IM_COL32(216, 216, 216, 255), theme::text); }+ImU32 kTextDim() { return lookColor(IM_COL32(140, 140, 144, 255), theme::textDim); }+ImU32 kPanelBg() { return lookColor(IM_COL32(37, 37, 40, 252), theme::panelBg, 0.99f); } // #252528, pop-ups// The left tray's colour field. These should become theme tokens (Theme.h) once the theme settles.constexpr ImU32 kFieldEdge = IM_COL32(14, 14, 16, 255); // 1 px around the SV square, hue strip and swatchesconstexpr ImU32 kFieldHairline = IM_COL32(255, 255, 255, 28); // inner highlight that lifts a swatch off the tray@@ -166,11 +170,11 @@ void quickInfo(ImTextureID tex, const char* glyph, const std::string& title, conelse if (glyph) {ImGui::Dummy(ImVec2(big, big));ImDrawList* dl = ImGui::GetWindowDrawList();- dl->AddRectFilled(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(), kTileBg, 4.0f);+ dl->AddRectFilled(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(), kTileBg(), theme::rounding(4.0f));const float fs = ImGui::GetFontSize() * 3.0f;const ImVec2 sz = ImGui::GetFont()->CalcTextSizeA(fs, FLT_MAX, 0, glyph);const ImVec2 c = ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax()).GetCenter();- dl->AddText(ImGui::GetFont(), fs, ImVec2(c.x - sz.x * 0.5f, c.y - sz.y * 0.5f), kGlyph, glyph);+ dl->AddText(ImGui::GetFont(), fs, ImVec2(c.x - sz.x * 0.5f, c.y - sz.y * 0.5f), kGlyph(), glyph);}ImGui::TextUnformatted(title.c_str());if (!text.empty()) {@@ -193,10 +197,10 @@ bool beginPickerWindow(const char* title, float width) {ImGui::SetNextWindowPos(pos, ImGuiCond_Appearing);ImGui::SetNextWindowSizeConstraints(ImVec2(width, 0), ImVec2(width, vp->Size.y - 60.0f));if (s.openedFrame == ImGui::GetFrameCount()) ImGui::SetNextWindowFocus();- ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 6.0f);+ ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, theme::rounding(6.0f));ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10, 8));- ImGui::PushStyleColor(ImGuiCol_WindowBg, kPanelBg);- ImGui::PushStyleColor(ImGuiCol_Border, IM_COL32(64, 64, 70, 255));+ ImGui::PushStyleColor(ImGuiCol_WindowBg, kPanelBg());+ ImGui::PushStyleColor(ImGuiCol_Border, lookColor(IM_COL32(64, 64, 70, 255), theme::tileBorder));const bool visible = ImGui::Begin(title, nullptr,ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize |ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings |@@ -250,38 +254,38 @@ bool AssetTile(const char* id, ImTextureID texture, const char* glyph, const stdconst bool hovered = ImGui::IsItemHovered();ImDrawList* dl = ImGui::GetWindowDrawList();const ImVec2 t0 = p, t1(p.x + thumbSize, p.y + thumbSize);- dl->AddRectFilled(t0, t1, hovered ? kTileHover : kTileBg, 4.0f);+ dl->AddRectFilled(t0, t1, hovered ? kTileHover() : kTileBg(), theme::rounding(4.0f));if (texture) {const float pad = 2.0f;dl->AddImageRounded(texture, ImVec2(t0.x + pad, t0.y + pad), ImVec2(t1.x - pad, t1.y - pad), ImVec2(0, 0),- ImVec2(1, 1), dim ? IM_COL32(255, 255, 255, 110) : IM_COL32_WHITE, 3.0f);+ ImVec2(1, 1), dim ? IM_COL32(255, 255, 255, 110) : IM_COL32_WHITE, theme::rounding(3.0f));} else if (glyph) {const float fs = std::round(thumbSize * 0.36f);const ImVec2 gs = ImGui::GetFont()->CalcTextSizeA(fs, FLT_MAX, 0, glyph);dl->AddText(ImGui::GetFont(), fs,- ImVec2(std::round((t0.x + t1.x - gs.x) * 0.5f), std::round((t0.y + t1.y - gs.y) * 0.5f)), kGlyph,+ ImVec2(std::round((t0.x + t1.x - gs.x) * 0.5f), std::round((t0.y + t1.y - gs.y) * 0.5f)), kGlyph(),glyph);}dl->AddRect(t0, t1,- selected ? kAccent- : hovered ? IM_COL32(90, 90, 96, 255)- : kTileBorder,- 4.0f, 0, selected ? 2.0f : 1.0f);+ selected ? kAccent()+ : hovered ? lookColor(IM_COL32(90, 90, 96, 255), theme::textDim)+ : kTileBorder(),+ theme::rounding(4.0f), 0, selected ? 2.0f : 1.0f);if (badge && *badge) {// The orange key of the brush pop-up: press it to pick this tile.const float fs = ImGui::GetFontSize();const ImVec2 bs = ImGui::CalcTextSize(badge);const ImVec2 b1(t1.x - 3.0f, t0.y + 3.0f + fs + 2.0f), b0(b1.x - std::max(bs.x + 8.0f, fs + 2.0f), t0.y + 3.0f);- dl->AddRectFilled(b0, b1, kAccent, 3.0f);- dl->AddText(ImVec2(std::round((b0.x + b1.x - bs.x) * 0.5f), b0.y + 1.0f), IM_COL32(20, 20, 22, 255), badge);+ dl->AddRectFilled(b0, b1, kAccent(), theme::rounding(3.0f));+ dl->AddText(ImVec2(std::round((b0.x + b1.x - bs.x) * 0.5f), b0.y + 1.0f), lookColor(IM_COL32(20, 20, 22, 255), theme::textOnAccent), badge);ImGui::LogText(" [%s]", badge);}const std::string shown = elide(label, thumbSize);const ImVec2 ls = ImGui::CalcTextSize(shown.c_str());dl->AddText(ImVec2(std::round(p.x + (thumbSize - ls.x) * 0.5f), t1.y + 2.0f),selected ? IM_COL32(255, 255, 255, 255)- : dim ? kTextDim- : kText,+ : dim ? kTextDim()+ : kText(),shown.c_str());ImGui::LogText(" %s", label.c_str()); // drawn directly: tell the log (UI tests read it) tooif (hovered) {@@ -313,11 +317,11 @@ void AssetTileHoverGlow() {ImDrawList* dl;~PopClip() { dl->PopClipRect(); }} pop{dl};- dl->AddRectFilled(ImVec2(a.x + 3, a.y + 5), ImVec2(b.x + 3, b.y + 5), IM_COL32(0, 0, 0, 90), 8.0f);- dl->AddRectFilled(a, b, IM_COL32(48, 48, 53, 255), 6.0f);+ dl->AddRectFilled(ImVec2(a.x + 3, a.y + 5), ImVec2(b.x + 3, b.y + 5), IM_COL32(0, 0, 0, 90), theme::rounding(8.0f));+ dl->AddRectFilled(a, b, lookColor(IM_COL32(48, 48, 53, 255), theme::header), theme::rounding(6.0f));dl->AddImageRounded(g.tex, ImVec2(a.x + 3, a.y + 3), ImVec2(b.x - 3, b.y - 3), ImVec2(0, 0), ImVec2(1, 1),- IM_COL32_WHITE, 5.0f);- dl->AddRect(a, b, IM_COL32(240, 136, 46, 160), 6.0f, 0, 1.5f);+ IM_COL32_WHITE, theme::rounding(5.0f));+ dl->AddRect(a, b, lookColor(IM_COL32(240, 136, 46, 160), theme::accent, 0.63f), theme::rounding(6.0f), 0, 1.5f);}// ---------------------------------------------------------------------------@@ -628,7 +632,7 @@ void drawBrushGrid(App& app, GridMode mode) {x = 0.0f;x += w + 3.0f;const bool on = !typed.empty() && typed[0] == char('a' + k);- if (on) ImGui::PushStyleColor(ImGuiCol_Button, ImGui::ColorConvertU32ToFloat4(kAccent));+ if (on) ImGui::PushStyleColor(ImGuiCol_Button, ImGui::ColorConvertU32ToFloat4(kAccent()));if (ImGui::SmallButton(text)) {if (popup)s.typed = std::string(1, char('a' + k));@@ -1147,9 +1151,9 @@ void drawPickers(App& app) {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_WindowRounding, theme::rounding(6.0f));ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(8, 8));- ImGui::PushStyleColor(ImGuiCol_WindowBg, kPanelBg);+ ImGui::PushStyleColor(ImGuiCol_WindowBg, kPanelBg());bool close = false;if (ImGui::Begin((std::string(d.name) + "##cursor").c_str(), nullptr,ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings |@@ -1352,12 +1356,12 @@ void App::drawColorWidget(float width) {ImGui::ColorConvertFloat4ToU32(ImVec4(r1, g1, b1, 1)), stripW * 0.5f,i == 0 ? ImDrawFlags_RoundCornersTop : i == 5 ? ImDrawFlags_RoundCornersBottom : ImDrawFlags_RoundCornersNone);}- dl->AddRect(hs, hsMax, kFieldEdge, stripW * 0.5f, 0, 1.0f * s);+ dl->AddRect(hs, hsMax, kFieldEdge, theme::rounding(stripW * 0.5f), 0, 1.0f * s);const float ny = std::clamp(hs.y + h * squareH, hs.y + 2.5f * s, hsMax.y - 2.5f * s);const ImVec2 na(hs.x - 1.0f * s, ny - 1.5f * s), nb(hsMax.x + 1.0f * s, ny + 1.5f * s);- dl->AddRect(ImVec2(na.x - 1.0f * s, na.y - 1.0f * s), ImVec2(nb.x + 1.0f * s, nb.y + 1.0f * s), kMarkerDark, 2.0f * s, 0,+ dl->AddRect(ImVec2(na.x - 1.0f * s, na.y - 1.0f * s), ImVec2(nb.x + 1.0f * s, nb.y + 1.0f * s), kMarkerDark, theme::rounding(2.0f * s), 0,1.0f * s);- dl->AddRectFilled(na, nb, kMarkerLight, 1.5f * s);+ dl->AddRectFilled(na, nb, kMarkerLight, theme::rounding(1.5f * s));ImGui::PopStyleVar();ImGui::PopID();diff --git a/src/app/Shell.cpp b/src/app/Shell.cppindex 7e35bf35..ac25e0dd 100644--- a/src/app/Shell.cpp+++ b/src/app/Shell.cpp@@ -10,6 +10,7 @@#include "app/Demo.h"#include "app/Shell.h"#include "app/Theme.h"+#include "app/LookSchemes.h"#include "app/Ui.h"#include "app/I18n.h"#include "core/Matcap.h"@@ -40,6 +41,37 @@ constexpr ImGuiWindowFlags kShellFlags = ImGuiWindowFlags_NoDecoration | ImGuiWiconst char* const kShelfWindows[kShelfCount] = {"##TopShelf", "##LeftShelf", "##RightShelf", "##BottomShelf"};+CanvasRect g_focus; // the tile under the pointer this frame (tiled looks draw its border in the accent)++bool sameRect(const CanvasRect& a, const CanvasRect& b) {+ return a.w > 0.0f && a.h > 0.0f && std::abs(a.x - b.x) < 0.5f && std::abs(a.y - b.y) < 0.5f && std::abs(a.w - b.w) < 0.5f &&+ std::abs(a.h - b.h) < 0.5f;+}++// A tiled look's frame around one region: a thin border (the accent on the focused tile), Blueprint's corner marks.+void tileFrame(ImDrawList* dl, const CanvasRect& r, bool focused) {+ if (!theme::look.tiled || r.w <= 0.0f || r.h <= 0.0f) return;+ const ImFontAtlas* atlas = ImGui::GetIO().Fonts;+ const float s = atlas && !atlas->Fonts.empty() ? atlas->Fonts[0]->FontSize / 15.0f : 1.0f; // the UI scale+ const float t = std::max(1.0f, std::floor(s + 0.25f)) * (focused ? 2.0f : 1.0f); // 2 px on the focused tile+ const ImVec2 a(r.x, r.y), b(r.x + r.w, r.y + r.h);+ dl->PushClipRect(a, b, false);+ dl->AddRect(ImVec2(a.x + t * 0.5f, a.y + t * 0.5f), ImVec2(b.x - t * 0.5f, b.y - t * 0.5f),+ theme::u32(focused ? theme::focusBorder : theme::tileBorder), 0.0f, 0, t);+ if (theme::look.headers == theme::LookStyle::Headers::Grid) { // registration marks at the corners+ const float k = std::min(9.0f, std::min(r.w, r.h) * 0.3f);+ const ImU32 c = theme::u32(theme::accent, focused ? 1.0f : 0.75f);+ const float w = 2.0f * t;+ for (int i = 0; i < 4; ++i) {+ const float x = i & 1 ? b.x - w * 0.5f : a.x + w * 0.5f, y = i & 2 ? b.y - w * 0.5f : a.y + w * 0.5f;+ const float dx = i & 1 ? -k : k, dy = i & 2 ? -k : k;+ dl->AddLine(ImVec2(x, y), ImVec2(x + dx, y), c, w);+ dl->AddLine(ImVec2(x, y), ImVec2(x, y + dy), c, w);+ }+ }+ dl->PopClipRect();+}+bool beginShellWindow(const char* name, const CanvasRect& r, const ImVec4& bg, ImVec2 padding,ImGuiWindowFlags extra = ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse) {ImGui::SetNextWindowPos(ImVec2(r.x, r.y));@@ -52,6 +84,7 @@ bool beginShellWindow(const char* name, const CanvasRect& r, const ImVec4& bg, Iconst bool open = ImGui::Begin(name, nullptr, kShellFlags | extra);ImGui::PopStyleColor();ImGui::PopStyleVar(4);+ if (open) tileFrame(ImGui::GetWindowDrawList(), r, sameRect(r, g_focus));return open;}@@ -248,7 +281,7 @@ bool drawShelfTile(App& app, const Action& a, ImVec2 size) {const bool mode = ui::IsModeAction(a.id);const ImVec4 bg = on ? (mode ? (hovered ? theme::accentHover : theme::accent) : hovered ? theme::toggleOnHover : theme::toggleOn): held ? theme::buttonPressed : hovered ? theme::buttonHover : theme::frame;- dl->AddRectFilled(p0, p1, theme::u32(bg, alpha), 4.0f * s);+ dl->AddRectFilled(p0, p1, theme::u32(bg, alpha), theme::rounding(4.0f * s));if (on && !mode) ui::DrawOnMark(dl, p0, p1, true);// Two text levels only: actions and hovered items in text, options that are off in textOff (readable, so// off doesn't look disabled); disabled items are faded by alpha.@@ -261,7 +294,7 @@ bool drawShelfTile(App& app, const Action& a, ImVec2 size) {// Tile: a square picture (brush thumbnail or icon) with the name under it.const float pic = std::min(size.x, size.y - capH);const ImVec2 q0(p0.x + (size.x - pic) * 0.5f, p0.y), q1(q0.x + pic, q0.y + pic);- dl->AddRectFilled(p0, p1, theme::u32(hovered ? theme::buttonHover : theme::tile, hovered ? 0.55f : 0.0f), 4.0f * s);+ dl->AddRectFilled(p0, p1, theme::u32(hovered ? theme::buttonHover : theme::tile, hovered ? 0.55f : 0.0f), theme::rounding(4.0f * s));ImTextureID tex = type >= 0 ? app.thumbnails().brush(type) : ImTextureID(0);if (a.id == "draw.paint") { // the Paint brush's own preview (Pickers.cpp)BrushItem paint;@@ -270,14 +303,14 @@ bool drawShelfTile(App& app, const Action& a, ImVec2 size) {}if (tex) {dl->AddImageRounded(tex, ImVec2(q0.x + 2 * s, q0.y + 2 * s), ImVec2(q1.x - 2 * s, q1.y - 2 * s), ImVec2(0, 0),- ImVec2(1, 1), IM_COL32(255, 255, 255, int(255 * alpha)), 4.0f * s);+ ImVec2(1, 1), IM_COL32(255, 255, 255, int(255 * alpha)), theme::rounding(4.0f * s));} else if (type >= 0) {drawBrushIcon(dl, ImVec2((q0.x + q1.x) * 0.5f, (q0.y + q1.y) * 0.5f), pic * 0.36f, type);} else {dl->AddCircleFilled(ImVec2((q0.x + q1.x) * 0.5f, (q0.y + q1.y) * 0.5f), pic * 0.36f, theme::u32(theme::tile), 32);centredText(dl, app.fontIcons_, q0, q1, theme::u32(on ? theme::accent : theme::text, alpha), a.icon ? a.icon : "?");}- if (on) dl->AddRect(p0, p1, theme::u32(theme::accent), 4.0f * s, 0, 2.0f * s);+ if (on) dl->AddRect(p0, p1, theme::u32(theme::accent), theme::rounding(4.0f * s), 0, 2.0f * s);// The hotkey digit (1-9, 0) in the corner, as ZBrush shows brush shortcuts.const std::string key = app.actions().shortcutText(a.id);if (key.size() == 1 && caption)@@ -584,6 +617,65 @@ void App::registerShellActions() {for (int i = 0; i < 3; ++i)add({"ui.preset." + std::to_string(i + 1), std::to_string(i + 1), nullptr, kPresetHelp[i], "Preferences > Layout", "","", [this, i] { applyPreset(i); }, nullptr, nullptr});+ // Preferences > Interface > Look: the looks and the two layouts, also from F3 and scripts (ui_look).+ for (int i = 0; i < int(looks::LookId::Count); ++i) {+ const looks::LookId look = looks::LookId(i);+ add({std::string("ui.look.") + looks::lookKey(look), std::string("Look: ") + looks::lookName(look), ICON_LC_PALETTE,+ std::string("Switch the interface to the ") + looks::lookName(look) + " look (Preferences > Interface > Look).",+ "Preferences > Interface > Look", "", "",+ [this, i] {+ uiPrefs_.look.look = i;+ if (i != 0) setShellLayout(1); // the looks come with the SculptForge layout (Preferences can switch back)+ lookDirty_ = true;+ },+ [this, i] { return uiPrefs_.look.look == i; }, nullptr});+ }+ add({"ui.layout.sculptforge", "SculptForge layout", ICON_LC_LAYOUT_DASHBOARD,+ "Menus by task (File, Edit, Sculpt, Paint, Mesh, View, Render, Help), a status bar and a one-row tool shelf.",+ "Preferences > Interface > Look", "", "", [this] { setShellLayout(1); lookDirty_ = true; },+ [this] { return uiPrefs_.shellLayout == 1; }, nullptr});+ add({"ui.layout.zbrush", "ZBrush-style layout", ICON_LC_LAYOUT_TEMPLATE,+ "The alphabetical palette bar and the two-row top shelf, as ZBrush users expect.", "Preferences > Interface > Look", "",+ "", [this] { setShellLayout(0); lookDirty_ = true; }, [this] { return uiPrefs_.shellLayout == 0; }, nullptr});+ commands_.add({"ui_look",+ "Interface look and layout (Preferences > Interface > Look). Only changes how the interface looks.",+ {{"look", ParamSpec::Type::String, "classic, forge, phosphor or blueprint (default: unchanged).", false},+ {"scheme", ParamSpec::Type::String,+ "Forge Terminal's colours: tokyo_night, catppuccin_mocha, gruvbox_dark, nord, rose_pine, kanagawa or everforest.",+ false},+ {"match_omarchy", ParamSpec::Type::Bool, "Forge Terminal: use the current Omarchy theme's colours (Linux).", false},+ {"phosphor", ParamSpec::Type::String, "Phosphor's colour: green or amber.", false},+ {"effects", ParamSpec::Type::Bool, "Phosphor's scanlines and glow (on the interface only).", false},+ {"layout", ParamSpec::Type::String, "sculptforge or zbrush (default: the look's, else unchanged).", false}},+ [this](Document&, const Args& a) -> CommandResult {+ theme::LookSettings& l = uiPrefs_.look;+ int layoutKind = uiPrefs_.shellLayout;+ if (a.contains("look")) {+ const std::string key = argString(a, "look");+ const looks::LookId id = looks::lookFromKey(key);+ if (id == looks::LookId::Classic && key != "classic") return {false, "look must be classic, forge, phosphor or blueprint"};+ l.look = int(id);+ if (id != looks::LookId::Classic) layoutKind = 1;+ }+ if (a.contains("scheme")) {+ const std::string key = argString(a, "scheme");+ if (!looks::findScheme(key)) return {false, "Unknown scheme " + key};+ l.scheme = key;+ }+ if (a.contains("match_omarchy")) l.matchOmarchy = argBool(a, "match_omarchy", false);+ if (a.contains("phosphor")) l.amber = argString(a, "phosphor") == "amber";+ if (a.contains("effects")) l.effects = argBool(a, "effects", false);+ if (a.contains("layout")) {+ const std::string k = argString(a, "layout");+ if (k != "sculptforge" && k != "zbrush") return {false, "layout must be sculptforge or zbrush"};+ layoutKind = k == "sculptforge" ? 1 : 0;+ }+ setShellLayout(layoutKind);+ lookDirty_ = true;+ return {true, std::string("Look: ") + looks::lookName(looks::LookId(l.look)) ++ (layoutKind == 1 ? ", SculptForge layout" : ", ZBrush-style layout")};+ }});+int count = 0;const PaletteDef* list = palettes(count);for (int i = 0; i < count; ++i) {@@ -643,14 +735,14 @@ float App::topInset() const {ShellGeometry App::shellGeometry() const {int w = 0, h = 0;SDL_GetWindowSize(window_, &w, &h);- return computeShell(layout_, float(w), float(h), uiScale_, topInset());+ return computeShell(layout_, float(w), float(h), uiScale_, topInset(), shellMetrics());}CanvasRect App::canvasRect() const {int w = 0, h = 0;SDL_GetWindowSize(window_, &w, &h);if (hideUi_) return {0.0f, 0.0f, float(std::max(w, 1)), float(std::max(h, 1))};- return computeShell(layout_, float(w), float(h), uiScale_, topInset()).canvas;+ return computeShell(layout_, float(w), float(h), uiScale_, topInset(), shellMetrics()).canvas;}void App::canvasRay(float x, float y, glm::vec3& origin, glm::vec3& dir) const {@@ -685,7 +777,7 @@ void App::updateCameraAspect() {void App::noteLayoutChanged() {}void App::applyPreset(int preset) {- UiLayout l = standardLayout();+ UiLayout l = standardLayout(uiPrefs_.shellLayout);l.customize = layout_.customize;l.consoleOpen = layout_.consoleOpen;l.consoleHeight = layout_.consoleHeight;@@ -742,12 +834,30 @@ void App::movePaletteToTray(const std::string& id, bool right) {void App::drawCanvasFrame() {const CanvasRect c = shell_.canvas;ImDrawList* dl = ImGui::GetBackgroundDrawList();+ if (theme::look.tiled) { // the 3D view is a tile too: its border just outside it, in the gap+ const float t = std::max(1.0f, std::floor(uiScale_));+ const CanvasRect frame{c.x - t, c.y - t, c.w + 2.0f * t, c.h + 2.0f * t};+ tileFrame(dl, frame, sameRect(c, g_focus));+ return;+ }dl->AddRect(ImVec2(c.x - 1.0f, c.y - 1.0f), ImVec2(c.x + c.w + 1.0f, c.y + c.h + 1.0f), theme::u32(theme::canvasBorder));}void App::drawShell() {const ImGuiViewport* vp = ImGui::GetMainViewport();- shell_ = computeShell(layout_, vp->Size.x, vp->Size.y, uiScale_, topInset());+ if (lookDirty_) { // Preferences > Interface > Look changed: applied here, outside any pushed style+ lookDirty_ = false;+ applyLook();+ }+ shell_ = computeShell(layout_, vp->Size.x, vp->Size.y, uiScale_, topInset(), shellMetrics());+ {+ const ImVec2 m = ImGui::GetIO().MousePos;+ g_focus = {};+ for (const CanvasRect* r : {&shell_.title, &shell_.paletteBar, &shell_.topShelf, &shell_.leftShelf, &shell_.rightShelf,+ &shell_.bottomShelf, &shell_.leftTray, &shell_.rightTray, &shell_.console, &shell_.canvas})+ if (r->w > 0.0f && r->h > 0.0f && r->contains(m.x, m.y)) g_focus = *r;+ focusRect_ = g_focus;+ }if (shell_.notchBand.h > 0.0f) // the band beside the camera: plain shell colour, so it reads as part of the bezelImGui::GetBackgroundDrawList()->AddRectFilled(ImVec2(0, 0), ImVec2(shell_.notchBand.w, shell_.notchBand.h),theme::u32(theme::shellBg));@@ -764,9 +874,11 @@ void App::drawShell() {statusSince_ = ImGui::GetTime();if (!lastCommandOk_) redrawIn(6.05); // the error colour below goes after 6 s, idle or not}+ drawLookChrome();drawCanvasFrame();- drawTitleStrip(shell_);- if (layout_.paletteBarVisible) drawPaletteBar(shell_);+ if (sculptForgeLayout()) drawStatusBar(shell_);+ else drawTitleStrip(shell_);+ if (layout_.paletteBarVisible && !sculptForgeLayout()) drawPaletteBar(shell_);if (shell_.shelves) {drawShelf(kShelfTop, shell_.topShelf);drawShelf(kShelfLeft, shell_.leftShelf);@@ -777,7 +889,8 @@ void App::drawShell() {drawDivider(false, shell_.leftDivider);drawDivider(true, shell_.rightDivider);}- drawPaletteDropdown();+ if (sculptForgeLayout()) drawTaskMenu();+ else drawPaletteDropdown();finishShelfDrag();}@@ -798,7 +911,7 @@ void App::drawTitleStrip(const ShellGeometry& g) {// App mark and name.ImGui::SetCursorPos(ImVec2(8.0f * s, textY));- ImGui::TextColored(theme::accent, ICON_LC_BOX);+ ImGui::TextColored(theme::brand, ICON_LC_BOX); // the brand mark keeps its orange in every lookImGui::SameLine(0.0f, 5.0f * s);if (fontBold_) ImGui::PushFont(fontBold_);ImGui::TextUnformatted("SculptForge");@@ -907,7 +1020,7 @@ void App::drawTitleStrip(const ShellGeometry& g) {const ImVec2 p = ImGui::GetCursorScreenPos();const bool clicked = ImGui::InvisibleButton("##search", ImVec2(searchW, buttonH));const bool hovered = ImGui::IsItemHovered();- dl->AddRectFilled(p, ImVec2(p.x + searchW, p.y + buttonH), theme::u32(hovered ? theme::frameHover : theme::frame), 3.0f * s);+ dl->AddRectFilled(p, ImVec2(p.x + searchW, p.y + buttonH), theme::u32(hovered ? theme::frameHover : theme::frame), theme::rounding(3.0f * s));const float ty = p.y + (buttonH - ImGui::GetFontSize()) * 0.5f;dl->AddText(ImVec2(p.x + 7.0f * s, ty), theme::u32(theme::textDim), tr(ICON_LC_SEARCH " Search"));const ImVec2 kw = ImGui::CalcTextSize("F3");@@ -926,7 +1039,7 @@ void App::drawTitleStrip(const ShellGeometry& g) {const bool hovered = ImGui::IsItemHovered();if (hovered)dl->AddRectFilled(p, ImVec2(p.x + windowButtonW, p.y + buttonH),- theme::u32(close ? theme::danger : theme::frameHover), 3.0f * s);+ theme::u32(close ? theme::danger : theme::frameHover), theme::rounding(3.0f * s));const char* glyph = close ? ICON_LC_X : ICON_LC_MINUS;const ImVec2 gs = ImGui::CalcTextSize(glyph);dl->AddText(ImVec2(p.x + (windowButtonW - gs.x) * 0.5f, p.y + (buttonH - ImGui::GetFontSize()) * 0.5f),@@ -981,7 +1094,7 @@ void App::drawPaletteBar(const ShellGeometry& g) {ImGui::PushStyleColor(ImGuiCol_Button, open ? theme::header : ImVec4(0, 0, 0, 0));ImGui::PushStyleColor(ImGuiCol_ButtonHovered, theme::headerHover);ImGui::PushStyleColor(ImGuiCol_ButtonActive, theme::header);- ImGui::PushStyleColor(ImGuiCol_Text, inTray ? theme::accent : open ? theme::textOnAccent : theme::text);+ ImGui::PushStyleColor(ImGuiCol_Text, inTray ? theme::accent : open ? theme::textHover : theme::text);const bool gap = !uiPrefs_.alphabeticalPalettes && (k == 2 || (help >= 0 && k + 1 == order.size()));if (i) ImGui::SameLine(0.0f, gap ? 10.0f * s : -1.0f); // small gaps after File, Edit and before Helpconst std::string label = std::string(tr(p.name)) + "##palette." + p.id;@@ -1007,6 +1120,500 @@ void App::drawPaletteBar(const ShellGeometry& g) {ImGui::End();}+// ---------------------------------------------------------------------------+// Looks and the SculptForge layout (Preferences > Interface > Look)+// ---------------------------------------------------------------------------++ShellMetrics App::shellMetrics() const {+ const float gap = theme::look.tiled ? theme::look.gap : 0.0f;+ if (sculptForgeLayout()) return sculptForgeMetrics(gap);+ ShellMetrics m;+ m.gap = gap;+ if (gap > 0.0f) m.dividerW = 0.0f; // the gaps beside the trays are the dividers+ return m;+}++void App::setShellLayout(int layoutKind) {+ layoutKind = std::clamp(layoutKind, 0, 1);+ if (uiPrefs_.shellLayout == layoutKind) return;+ uiPrefs_.shellLayout = layoutKind;+ // The shelves change to that layout's standard ones; the trays, the console and the Library stay as they are.+ UiLayout l = standardLayout(layoutKind);+ l.customize = layout_.customize;+ l.leftTray = layout_.leftTray;+ l.rightTray = layout_.rightTray;+ l.leftTrayOpen = layout_.leftTrayOpen;+ l.rightTrayOpen = layout_.rightTrayOpen;+ l.leftTrayWidth = layout_.leftTrayWidth;+ l.rightTrayWidth = layout_.rightTrayWidth;+ l.openSubpalettes = layout_.openSubpalettes;+ l.consoleOpen = layout_.consoleOpen;+ l.consoleHeight = layout_.consoleHeight;+ l.lightboxOpen = layout_.lightboxOpen;+ l.lightboxRows = layout_.lightboxRows;+ l.lightboxTab = layout_.lightboxTab;+ l.lightboxBottom = layout_.lightboxBottom;+ l.leftHanded = layout_.leftHanded;+ l.shelfTiles = layout_.shelfTiles;+ layout_ = std::move(l);+ dropdown_.clear();+ updateCameraAspect();+}++void App::applyLook() {+ std::string message;+ theme::applyLook(uiPrefs_.look, &message);+ ImGui::GetStyle().ScaleAllSizes(uiScale_);+ const bool mono = theme::look.monoLabels || theme::look.monoAll;+ if (fontInterSmall_) {+ fontSmall_ = mono && fontMonoSmall_ ? fontMonoSmall_ : fontInterSmall_;+ fontTiny_ = mono && fontMonoTiny_ ? fontMonoTiny_ : fontInterTiny_;+ fontBold_ = mono && fontMonoBold_ ? fontMonoBold_ : fontInterBold_;+ }+ ImGui::GetIO().FontDefault = theme::look.monoAll && fontMono_ ? fontMono_ : nullptr; // nullptr: Inter, the first font+ ImVec4 centre, edge; // the 3D view's gradient background (a flat background the user picked stays as it is)+ theme::lookViewportGradient(centre, edge);+ renderSettings_.gradientCentre = glm::vec3(centre.x, centre.y, centre.z);+ renderSettings_.gradientEdge = glm::vec3(edge.x, edge.y, edge.z);+ if (!message.empty()) {+ status_ = message;+ lastCommandOk_ = false;+ }+ updateCameraAspect();+ redrawIn(0.0);+}++// The wallpaper in a tiled look's gaps, and Phosphor's optional effects. Nothing here ever covers the 3D view.+void App::drawLookChrome() {+ if (!theme::look.tiled) return;+ const ImGuiViewport* vp = ImGui::GetMainViewport();+ const float W = vp->Size.x, H = vp->Size.y, s = uiScale_;+ const CanvasRect& c = shell_.canvas;+ ImDrawList* bg = ImGui::GetBackgroundDrawList();+ const ImU32 wall = theme::u32(theme::gapBg);+ // Four bands around the canvas.+ bg->AddRectFilled(ImVec2(0, 0), ImVec2(W, c.y), wall);+ bg->AddRectFilled(ImVec2(0, c.y + c.h), ImVec2(W, H), wall);+ bg->AddRectFilled(ImVec2(0, c.y), ImVec2(c.x, c.y + c.h), wall);+ bg->AddRectFilled(ImVec2(c.x + c.w, c.y), ImVec2(W, c.y + c.h), wall);+ if (theme::look.headers == theme::LookStyle::Headers::Grid) { // drafting paper in the gaps+ const float step = 12.0f * s;+ const ImU32 fine = theme::u32(theme::accent, 0.07f), major = theme::u32(theme::accent, 0.16f);+ auto outsideCanvas = [&](float x0, float y0, float x1, float y1) { return x1 <= c.x || x0 >= c.x + c.w || y1 <= c.y || y0 >= c.y + c.h; };+ for (int i = 0; float(i) * step < W; ++i) {+ const float x = std::floor(float(i) * step) + 0.5f;+ const ImU32 col = i % 5 == 0 ? major : fine;+ if (outsideCanvas(x, 0, x + 1, H)) bg->AddLine(ImVec2(x, 0), ImVec2(x, H), col);+ else {+ bg->AddLine(ImVec2(x, 0), ImVec2(x, c.y), col);+ bg->AddLine(ImVec2(x, c.y + c.h), ImVec2(x, H), col);+ }+ }+ for (int i = 0; float(i) * step < H; ++i) {+ const float y = std::floor(float(i) * step) + 0.5f;+ const ImU32 col = i % 5 == 0 ? major : fine;+ if (outsideCanvas(0, y, W, y + 1)) bg->AddLine(ImVec2(0, y), ImVec2(W, y), col);+ else {+ bg->AddLine(ImVec2(0, y), ImVec2(c.x, y), col);+ bg->AddLine(ImVec2(c.x + c.w, y), ImVec2(W, y), col);+ }+ }+ }+ if (theme::look.glow && g_focus.w > 0.0f) { // a soft phosphor bloom around the focused tile, in the gap+ for (int k = 1; k <= 4; ++k) {+ const float d = float(k) * s;+ bg->AddRect(ImVec2(g_focus.x - d, g_focus.y - d), ImVec2(g_focus.x + g_focus.w + d, g_focus.y + g_focus.h + d),+ theme::u32(theme::accent, 0.28f / float(k)), 0.0f, 0, 1.0f * s);+ }+ }+ if (theme::look.scanlines) { // over the chrome (shells, menus, pop-ups), never over the 3D view+ ImDrawList* fg = ImGui::GetForegroundDrawList();+ const float step = std::max(2.0f, std::floor(3.0f * s));+ const ImU32 line = IM_COL32(0, 0, 0, 46);+ for (float y = 0.5f; y < H; y += step) {+ if (y < c.y || y > c.y + c.h) fg->AddLine(ImVec2(0, y), ImVec2(W, y), line);+ else {+ fg->AddLine(ImVec2(0, y), ImVec2(c.x - 1.0f, y), line);+ fg->AddLine(ImVec2(c.x + c.w + 1.0f, y), ImVec2(W, y), line);+ }+ }+ }+}++namespace {++std::string upper(std::string s) {+ for (auto& c : s) c = char(std::toupper(static_cast<unsigned char>(c)));+ return s;+}++struct StatusModule {+ const char* icon;+ std::string label; // "brush"+ std::string value; // "Clay"+ bool mode = false; // the mode block (filled with the accent)+};++} // namespace++void App::drawStatusBar(const ShellGeometry& g) {+ const float s = uiScale_;+ if (!beginShellWindow("##TitleStrip", g.title, theme::shellBg, ImVec2(0.0f, 0.0f))) {+ ImGui::End();+ return;+ }+ using Status = theme::LookStyle::Status;+ const Status style = theme::look.status == Status::Plain ? Status::Modules : theme::look.status;+ ImDrawList* dl = ImGui::GetWindowDrawList();+ const ImVec2 o(g.title.x, g.title.y);+ const float h = g.title.h;+ const float inset = theme::look.tiled ? std::max(1.0f, std::floor(s)) : 0.0f; // inside the tile border+ if (!theme::look.tiled)+ dl->AddLine(ImVec2(o.x, o.y + h - 1.0f), ImVec2(o.x + g.title.w, o.y + h - 1.0f), theme::u32(theme::border));+ if (theme::look.headers == theme::LookStyle::Headers::Grid) { // Blueprint: the bar is a drawing's title block+ const float step = 6.0f * s;+ for (float x = o.x + step; x < o.x + g.title.w; x += step)+ dl->AddLine(ImVec2(std::floor(x) + 0.5f, o.y + inset), ImVec2(std::floor(x) + 0.5f, o.y + h - inset), theme::u32(theme::accent, 0.035f));+ }+ // The bar's readouts in the look's small font: monospace in the looks, Inter in Classic.+ ImFont* monoSmall = theme::look.id != 0 && fontMonoSmall_ ? fontMonoSmall_ : fontSmall_ ? fontSmall_ : ImGui::GetFont();+ ImFont* bold = fontBold_ ? fontBold_ : ImGui::GetFont();+ auto textW = [](ImFont* f, const std::string& t) { return f->CalcTextSizeA(f->FontSize, FLT_MAX, 0.0f, t.c_str()).x; };+ auto textAt = [&](ImFont* f, float x, const ImVec4& col, const std::string& t) {+ dl->AddText(f, f->FontSize, ImVec2(std::floor(x), std::floor(o.y + (h - f->FontSize) * 0.5f)), theme::u32(col), t.c_str());+ return x + textW(f, t);+ };++ // Brand: the cube in the SculptForge orange, the name.+ float x = o.x + 12.0f * s;+ x = textAt(ImGui::GetFont(), x, theme::brand, ICON_LC_BOX) + 6.0f * s;+ const bool caps = style == Status::Terminal;+ x = textAt(bold, x, theme::textBright, caps ? "SCULPTFORGE" : "SculptForge");+ x += (style == Status::TitleBlock ? 14.0f : 18.0f) * s;+ if (style == Status::TitleBlock || style == Status::Terminal) {+ dl->AddLine(ImVec2(std::floor(x) + 0.5f, o.y + inset), ImVec2(std::floor(x) + 0.5f, o.y + h - inset), theme::u32(theme::tileBorder));+ x += 8.0f * s;+ }++ // The task menus.+ int menuCount = 0;+ const TaskMenuDef* menus = taskMenus(menuCount);+ const int openMenu = dropdown_.empty() ? -1 : taskMenuOf(dropdown_);+ ImFont* menuFont = style == Status::Modules ? ImGui::GetFont() : monoSmall;+ for (int i = 0; i < menuCount; ++i) {+ const TaskMenuDef& m = menus[i];+ const std::string shown = style == Status::Modules ? std::string(tr(m.name)) : upper(tr(m.name));+ const float w = textW(menuFont, shown) + 16.0f * s;+ ImGui::SetCursorScreenPos(ImVec2(x, o.y + inset));+ const std::string id = std::string(tr(m.name)) + "##menu." + m.id;+ const bool pressed = ImGui::InvisibleButton(id.c_str(), ImVec2(w, h - 2.0f * inset));+ const bool hovered = ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup);+ const bool open = openMenu == i;+ const ImVec2 a = ImGui::GetItemRectMin(), b = ImGui::GetItemRectMax();+ if (open || hovered) {+ if (style == Status::Terminal && open) dl->AddRectFilled(a, b, theme::u32(theme::accent)); // inverse video+ else dl->AddRectFilled(a, b, theme::u32(open ? theme::selection : theme::headerHover, open ? 1.0f : 0.7f));+ }+ if (open && style != Status::Terminal) dl->AddRectFilled(ImVec2(a.x, b.y - 2.0f * s), b, theme::u32(theme::accent));+ const ImVec4 col = open ? (style == Status::Terminal ? theme::textOnAccent : theme::textBright) : theme::text;+ textAt(menuFont, a.x + 8.0f * s, col, shown);+ ImGui::LogText("%s", tr(m.name));+ ui::HelpText(m.name, nullptr, "Open this menu. Its sections are the palettes of the ZBrush-style layout.", "Menus");+ // Click to open or close; while one is open, pointing at another menu switches to it, as in a menu bar.+ const bool switchTo = openMenu >= 0 && !open && hovered;+ if (pressed || switchTo) {+ if (open && pressed) {+ dropdown_.clear();+ } else {+ // The section shown last, else the first one; one that sits in a tray is already on screen, so the+ // menu opens on the next one (a menu whose sections are all in trays flashes the tray instead).+ auto inTray = [&](const std::string& id) {+ return std::count(layout_.leftTray.begin(), layout_.leftTray.end(), id) ++ std::count(layout_.rightTray.begin(), layout_.rightTray.end(), id) >+ 0;+ };+ std::string section = menuSection_[m.id];+ if (section.empty() || taskMenuOf(section) != i || inTray(section)) {+ section.clear();+ for (int k = 0; k < 6 && m.sections[k] && section.empty(); ++k)+ if (!inTray(m.sections[k])) section = m.sections[k];+ }+ if (section.empty()) {+ flashPalette_ = m.sections[0];+ flashStart_ = ImGui::GetTime();+ } else {+ dropdown_ = section;+ menuX_ = a.x;+ openDropdown_ = true;+ }+ }+ }+ x += w + (style == Status::Modules ? 2.0f : 0.0f) * s;+ }+ const float menusEnd = x + 12.0f * s;++ // Right side, measured first: window controls, search, the layout presets as workspaces, then the modules.+ const float buttonH = h - 2.0f * inset - 8.0f * s;+ const float winW = buttonH + 8.0f * s;+ const float searchW = 150.0f * s;+ float right = o.x + g.title.w - 6.0f * s - inset;+ const float closeX = right - 2.0f * winW - 2.0f * s;+ right = closeX - 10.0f * s;+ const float searchX = right - searchW;+ right = searchX - 10.0f * s;+ const float wsW = buttonH + 4.0f * s;+ const float presetsX = right - 3.0f * wsW - 2.0f * s;+ right = presetsX - 14.0f * s;++ // Modules: mode, brush, document, triangles, frame rate.+ std::vector<StatusModule> mods;+ {+ const char* mode = paintMode_ ? "Paint" : "Sculpt";+ for (const char* t : {"tool.move", "tool.scale", "tool.rotate"})+ if (const Action* a = actions_.find(t); a && a->checked && a->checked()) mode = a->label.c_str();+ mods.push_back({ICON_LC_SQUARE_TERMINAL, "mode", upper(tr(mode)), true});+ std::string brush = brushName(brush_);+ if (doc_.activeBrush >= 0 && doc_.activeBrush < int(doc_.brushes.size())) brush = doc_.brushes[size_t(doc_.activeBrush)].name;+ mods.push_back({ICON_LC_BRUSH, "brush", brush});+ std::string name = doc_.path.empty() ? std::string(tr("Untitled"))+ : std::filesystem::path(std::u8string(doc_.path.begin(), doc_.path.end())).filename().string();+ if (doc_.dirty()) name += " *";+ mods.push_back({ICON_LC_FILE, "file", name});+ size_t tris = 0;+ for (int i = 0; i < doc_.subtoolCount(); ++i) tris += doc_.subtoolMesh(i).triangleCount();+ mods.push_back({ICON_LC_TRIANGLE, "tris", shortCount(tris)});+ if (ImGui::GetTime() - fpsShownAt_ > 0.5 || fpsShown_ < 0.0f) {+ fpsShown_ = ImGui::GetIO().Framerate;+ fpsShownAt_ = ImGui::GetTime();+ }+ char fps[16];+ std::snprintf(fps, sizeof fps, "%3.0f", fpsShown_);+ mods.push_back({ICON_LC_ACTIVITY, "fps", fps});+ }+ ImFont* labelFont = theme::look.id != 0 && fontMonoTiny_ ? fontMonoTiny_ : fontTiny_ ? fontTiny_ : monoSmall;+ auto moduleW = [&](const StatusModule& m) {+ switch (style) {+ case Status::Terminal:+ return m.mode ? textW(monoSmall, "[" + m.value + "]") + 10.0f * s : textW(monoSmall, m.label + ":" + m.value);+ case Status::TitleBlock:+ return textW(labelFont, upper(m.label)) + 6.0f * s + textW(m.mode ? monoSmall : monoSmall, m.value) + 20.0f * s;+ default:+ return m.mode ? textW(monoSmall, m.value) + 20.0f * s : textW(monoSmall, std::string(m.icon) + " " + m.value);+ }+ };+ const float sepW = style == Status::Terminal ? textW(monoSmall, " | ") : style == Status::TitleBlock ? 0.0f : 16.0f * s;+ // Drop the least important modules (from the file name inwards) until they fit beside the menus.+ std::vector<int> shown = {0, 1, 2, 3, 4};+ auto total = [&] {+ float w = 0.0f;+ for (size_t k = 0; k < shown.size(); ++k) w += moduleW(mods[size_t(shown[k])]) + (k ? sepW : 0.0f);+ return w;+ };+ for (int drop : {2, 4, 1})+ if (total() > right - menusEnd - 120.0f * s) shown.erase(std::remove(shown.begin(), shown.end(), drop), shown.end());+ float mx = right - total();+ const float modulesX = mx;+ for (size_t k = 0; k < shown.size(); ++k) {+ const StatusModule& m = mods[size_t(shown[k])];+ const float w = moduleW(m);+ if (k) {+ if (style == Status::Terminal) textAt(monoSmall, mx, theme::textDim, " | ");+ mx += sepW;+ }+ const float y0 = o.y + inset, y1 = o.y + h - inset;+ switch (style) {+ case Status::Terminal:+ if (m.mode) {+ dl->AddRectFilled(ImVec2(mx, y0 + 5.0f * s), ImVec2(mx + w, y1 - 5.0f * s), theme::u32(theme::accent));+ textAt(monoSmall, mx + 5.0f * s, theme::textOnAccent, "[" + m.value + "]");+ } else {+ const float lx = textAt(monoSmall, mx, theme::textDim, m.label + ":");+ textAt(monoSmall, lx, theme::text, m.value);+ }+ break;+ case Status::TitleBlock: {+ dl->AddLine(ImVec2(std::floor(mx) + 0.5f, y0), ImVec2(std::floor(mx) + 0.5f, y1), theme::u32(theme::tileBorder));+ const float lx = textAt(labelFont, mx + 10.0f * s, theme::textDim, upper(m.label)) + 6.0f * s;+ textAt(monoSmall, lx, m.mode ? theme::accent : theme::textBright, m.value);+ break;+ }+ default:+ if (m.mode) {+ dl->AddRectFilled(ImVec2(mx, y0 + 4.0f * s), ImVec2(mx + w, y1 - 4.0f * s), theme::u32(theme::accent));+ textAt(monoSmall, mx + 10.0f * s, theme::textOnAccent, m.value);+ } else {+ const float ix = textAt(monoSmall, mx, theme::accent, m.icon);+ textAt(monoSmall, ix + textW(monoSmall, " "), theme::text, m.value);+ }+ }+ mx += w;+ }+ if (style == Status::TitleBlock)+ dl->AddLine(ImVec2(std::floor(mx + 10.0f * s) + 0.5f, o.y + inset), ImVec2(std::floor(mx + 10.0f * s) + 0.5f, o.y + h - inset),+ theme::u32(theme::tileBorder));++ // The status message between the menus and the modules: what just happened.+ {+ const std::string msg = layout_.customize ? std::string(tr("Customize: Ctrl+Alt+drag to move or remove items")) : tr(status_);+ const float avail = modulesX - menusEnd - 16.0f * s;+ if (!msg.empty() && avail > 60.0f * s) {+ const bool error = !layout_.customize && !lastCommandOk_ && ImGui::GetTime() - statusSince_ < 6.0;+ const std::string text = (style == Status::Terminal ? "> " : "") + msg;+ textAt(monoSmall, menusEnd, error ? theme::danger : theme::textDim, elide(monoSmall, text, avail));+ }+ }++ // Layout presets 1 2 3, drawn as workspaces.+ for (int i = 1; i <= 3; ++i) {+ const std::string id = "ui.preset." + std::to_string(i);+ ImGui::SetCursorScreenPos(ImVec2(presetsX + float(i - 1) * (wsW + 1.0f * s), o.y + (h - buttonH) * 0.5f));+ const Action* a = actions_.find(id);+ const bool clicked = ImGui::InvisibleButton((std::to_string(i) + "##" + id).c_str(), ImVec2(wsW, buttonH));+ const bool hovered = ImGui::IsItemHovered();+ const ImVec2 a0 = ImGui::GetItemRectMin(), a1 = ImGui::GetItemRectMax();+ if (hovered) dl->AddRectFilled(a0, a1, theme::u32(theme::headerHover));+ const std::string n = std::to_string(i);+ textAt(monoSmall, a0.x + (wsW - textW(monoSmall, n)) * 0.5f, hovered ? theme::textBright : theme::textDim, n);+ if (clicked && a && a->run) a->run();+ ui::HelpAction(*this, id.c_str());+ }++ // Search: opens the command palette (F3), which also finds every palette of the ZBrush-style layout.+ {+ ImGui::SetCursorScreenPos(ImVec2(searchX, o.y + (h - buttonH) * 0.5f));+ const bool clicked = ImGui::InvisibleButton("##search", ImVec2(searchW, buttonH));+ const bool hovered = ImGui::IsItemHovered();+ const ImVec2 p = ImGui::GetItemRectMin();+ dl->AddRectFilled(p, ImVec2(p.x + searchW, p.y + buttonH), theme::u32(hovered ? theme::frameHover : theme::frame));+ if (theme::look.tiled) dl->AddRect(p, ImVec2(p.x + searchW, p.y + buttonH), theme::u32(theme::tileBorder));+ const char* prompt = style == Status::Terminal ? "> search" : style == Status::TitleBlock ? ICON_LC_SEARCH " SEARCH" : ICON_LC_SEARCH " search";+ textAt(monoSmall, p.x + 8.0f * s, theme::textDim, prompt);+ textAt(monoSmall, p.x + searchW - textW(monoSmall, "F3") - 8.0f * s, theme::accent, "F3");+ if (clicked) {+ if (const Action* a = actions_.find("ui.command_palette"); a && a->run) a->run();+ }+ ui::HelpText("Search", "F3", "Find any command, palette, brush or material by name and run it.", "Title");+ }++ // Window controls: minimise, and close (asks to save changes first).+ for (int k = 0; k < 2; ++k) {+ const bool close = k == 1;+ ImGui::SetCursorScreenPos(ImVec2(closeX + float(k) * (winW + 2.0f * s), o.y + (h - buttonH) * 0.5f));+ const bool clicked = ImGui::InvisibleButton(close ? "Close##window" : "Minimize##window", ImVec2(winW, buttonH));+ const bool hovered = ImGui::IsItemHovered();+ const ImVec2 p = ImGui::GetItemRectMin();+ if (hovered) dl->AddRectFilled(p, ImVec2(p.x + winW, p.y + buttonH), theme::u32(close ? theme::danger : theme::frameHover));+ centredText(dl, nullptr, p, ImVec2(p.x + winW, p.y + buttonH), theme::u32(hovered && close ? theme::textOnAccent : theme::textDim),+ close ? ICON_LC_X : ICON_LC_MINUS);+ if (close) {+ if (clicked) requestQuit();+ ui::HelpAction(*this, "file.quit");+ } else {+ if (clicked) SDL_MinimizeWindow(window_);+ ui::HelpText("Minimize", nullptr, "Minimize the SculptForge window.", "Title");+ }+ }+ ImGui::End();+}++// A task menu's drop-down: its sections (palettes) down the left, the chosen one beside them, under its header (whose+// tray icon still pins it to a tray). dropdown_ is the chosen palette, so ui.palette.* and F3 open it in its menu.+void App::drawTaskMenu() {+ if (openDropdown_) {+ ImGui::OpenPopup("##palettedropdown");+ openDropdown_ = false;+ }+ if (dropdown_.empty()) return;+ const int menuIndex = taskMenuOf(dropdown_);+ const PaletteDef* def = findPalette(dropdown_);+ if (menuIndex < 0 || !def) {+ dropdown_.clear();+ return;+ }+ int count = 0;+ const TaskMenuDef& menu = taskMenus(count)[menuIndex];+ menuSection_[menu.id] = dropdown_;+ int sections = 0;+ while (sections < 6 && menu.sections[sections]) ++sections;+ const float s = uiScale_;+ const ImGuiViewport* vp = ImGui::GetMainViewport();+ const float listW = sections > 1 ? 168.0f * s : 0.0f, bodyW = 320.0f * s;+ const float pad = std::round(6.0f * s);+ const float w = listW + bodyW + 2.0f * pad + (sections > 1 ? pad : 0.0f);+ const float y = shell_.title.y + shell_.title.h + (theme::look.tiled ? 2.0f * s : 0.0f);+ float x = menuX_;+ if (x <= 0.0f) { // opened by F3 or a key: under its name in the status bar+ 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));+ ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(pad, pad));+ const bool open = ImGui::BeginPopup("##palettedropdown");+ ImGui::PopStyleVar();+ if (!open) {+ dropdown_.clear();+ menuX_ = 0.0f;+ return;+ }+ ImDrawList* dl = ImGui::GetWindowDrawList();+ if (sections > 1) {+ ImGui::BeginGroup();+ ImFont* capFont = fontTiny_ ? fontTiny_ : ImGui::GetFont();+ ImGui::PushFont(capFont);+ ImGui::TextColored(theme::textDim, "%s", upper(tr(menu.name)).c_str());+ ImGui::PopFont();+ for (int k = 0; k < sections; ++k) {+ const PaletteDef* p = findPalette(menu.sections[k]);+ if (!p) continue;+ const std::string title = tr(menu.titles[k] ? menu.titles[k] : p->name);+ const bool current = dropdown_ == p->id;+ const bool inTray = std::count(layout_.leftTray.begin(), layout_.leftTray.end(), p->id) ++ std::count(layout_.rightTray.begin(), layout_.rightTray.end(), p->id) >+ 0;+ const float rowH = 28.0f * s;+ const bool clicked = ImGui::InvisibleButton((title + "##section." + p->id).c_str(), ImVec2(listW, rowH));+ const bool hovered = ImGui::IsItemHovered();+ const ImVec2 a = ImGui::GetItemRectMin(), b = ImGui::GetItemRectMax();+ if (current || hovered) dl->AddRectFilled(a, b, theme::u32(current ? theme::selection : theme::headerHover, current ? 1.0f : 0.6f));+ if (current) dl->AddRectFilled(a, ImVec2(a.x + 2.0f * s, b.y), theme::u32(theme::accent));+ const float ty = std::floor(a.y + (rowH - ImGui::GetFontSize()) * 0.5f);+ dl->AddText(ImVec2(a.x + 10.0f * s, ty), theme::u32(current ? theme::accent : theme::textDim), p->icon);+ dl->AddText(ImVec2(a.x + 34.0f * s, ty), theme::u32(current ? theme::textBright : theme::text), title.c_str());+ if (inTray) dl->AddText(ImVec2(b.x - 22.0f * s, ty), theme::u32(theme::textDim), ICON_LC_PANEL_RIGHT);+ if (clicked) {+ if (inTray) {+ flashPalette_ = p->id;+ flashStart_ = ImGui::GetTime();+ } else {+ dropdown_ = p->id;+ }+ }+ ui::HelpText(title.c_str(), nullptr, inTray ? "This palette is in a tray: click to find it there." : "Show this section.",+ tr(menu.name));+ }+ ImGui::EndGroup();+ const ImVec2 a = ImGui::GetItemRectMin(), b = ImGui::GetItemRectMax();+ const float lineX = std::floor(b.x + pad * 0.5f) + 0.5f;+ dl->AddLine(ImVec2(lineX, a.y), ImVec2(lineX, std::max(b.y, ImGui::GetWindowPos().y + ImGui::GetWindowHeight() - pad)),+ theme::u32(theme::tileBorder));+ ImGui::SameLine(0.0f, pad);+ }+ ImGui::BeginGroup();+ def = findPalette(dropdown_); // a section click may have changed it+ if (def) {+ Demo::pushScope(def->name);+ if (def->scope) Demo::pushScope(def->scope);+ const std::string id = dropdown_;+ if (paletteHeader(id.c_str(), false, true)) drawPaletteBody(id);+ if (def->scope) Demo::popScope();+ Demo::popScope();+ }+ ImGui::EndGroup();+ if (ImGui::IsKeyPressed(ImGuiKey_Escape) && !ImGui::IsAnyItemActive()) ImGui::CloseCurrentPopup();+ ImGui::EndPopup();+}+bool App::paletteHeader(const char* id, bool inTray, bool right) {const PaletteDef* def = findPalette(id);if (!def) return false;@@ -1016,7 +1623,18 @@ bool App::paletteHeader(const char* id, bool inTray, bool right) {const ImVec2 p = ImGui::GetCursorScreenPos();const float w = ImGui::GetContentRegionAvail().x;const bool collapsed = inTray && std::count(collapsedPalettes_.begin(), collapsedPalettes_.end(), id) > 0;- dl->AddRectFilled(p, ImVec2(p.x + w, p.y + h), theme::u32(theme::header), 3.0f * s);+ using Headers = theme::LookStyle::Headers;+ const Headers headers = theme::look.headers;+ if (headers != Headers::Ascii) dl->AddRectFilled(p, ImVec2(p.x + w, p.y + h), theme::u32(theme::header), theme::rounding(3.0f * s));+ if (headers == Headers::Grid) { // drafting grid in the header, a cyan base line+ const float step = 6.0f * s;+ const ImU32 g = theme::u32(theme::accent, 0.10f);+ for (float x = p.x + step; x < p.x + w; x += step) dl->AddLine(ImVec2(std::floor(x) + 0.5f, p.y), ImVec2(std::floor(x) + 0.5f, p.y + h), g);+ for (float y = p.y + step; y < p.y + h; y += step) dl->AddLine(ImVec2(p.x, std::floor(y) + 0.5f), ImVec2(p.x + w, std::floor(y) + 0.5f), g);+ dl->AddLine(ImVec2(p.x, p.y + h - 0.5f), ImVec2(p.x + w, p.y + h - 0.5f), theme::u32(theme::accent, 0.8f));+ } else if (headers == Headers::Bar) { // a terminal pane's title: the accent rule under it+ dl->AddLine(ImVec2(p.x, p.y + h - 0.5f), ImVec2(p.x + w, p.y + h - 0.5f), theme::u32(theme::accent, 0.7f));+ }// Tray icon: in a drop-down it moves the palette into the right tray (Shift: left) or can be dragged to one;// in a tray it sends the palette back to the bar.@@ -1038,15 +1656,30 @@ bool App::paletteHeader(const char* id, bool inTray, bool right) {const bool titleClicked = ImGui::InvisibleButton("##title", ImVec2(std::max(1.0f, w - 2.0f * h), h));const bool titleHovered = ImGui::IsItemHovered();if (fontBold_) ImGui::PushFont(fontBold_);- dl->AddText(ImVec2(p.x + h + 2.0f * s, p.y + (h - ImGui::GetFontSize()) * 0.5f),- theme::u32(titleHovered && inTray ? theme::textOnAccent : theme::text), tr(def->name));+ {+ std::string title = tr(def->name);+ if (theme::look.upperHeaders)+ for (auto& c : title) c = char(std::toupper(static_cast<unsigned char>(c)));+ if (headers == Headers::Ascii) title = "[ " + title + " ]";+ const ImVec2 tp(p.x + h + 2.0f * s, p.y + (h - ImGui::GetFontSize()) * 0.5f);+ const ImVec4 col = titleHovered && inTray ? theme::textHover : headers == Headers::Bar || headers == Headers::Ascii ? theme::accent : theme::text;+ dl->AddText(tp, theme::u32(col), title.c_str());+ if (headers == Headers::Ascii) { // [ TOOL ]--------------- up to the end icon+ const float x0 = tp.x + ImGui::CalcTextSize(title.c_str()).x + 4.0f * s, x1 = p.x + w - h - 2.0f * s;+ ImFont* f = ImGui::GetFont();+ const float cw = f->CalcTextSizeA(f->FontSize, FLT_MAX, 0.0f, "\xe2\x94\x80").x;+ std::string run;+ for (float x = x0; cw > 0.0f && x + cw <= x1; x += cw) run += "\xe2\x94\x80";+ dl->AddText(ImVec2(x0, tp.y), theme::u32(theme::accent, 0.55f), run.c_str());+ }+ }ImGui::LogText("%s", tr(def->name));if (fontBold_) ImGui::PopFont();ImGui::SameLine();const bool endClicked = ImGui::InvisibleButton(inTray ? "##collapse" : "##close", ImVec2(h, h));const bool endHovered = ImGui::IsItemHovered();centredText(dl, nullptr, ImVec2(p.x + w - h, p.y), ImVec2(p.x + w, p.y + h),- theme::u32(endHovered ? theme::textOnAccent : theme::textDim),+ theme::u32(endHovered ? theme::textHover : theme::textDim),inTray ? (collapsed ? ICON_LC_CHEVRON_RIGHT : ICON_LC_CHEVRON_DOWN) : ICON_LC_X);ImGui::PopStyleVar();ImGui::Dummy(ImVec2(0, 2.0f * s));@@ -1144,7 +1777,7 @@ void App::drawTray(bool right, const CanvasRect& r) {if (t < 0.9) {const float a = float(0.45 * (1.0 - t / 0.9));ImGui::GetWindowDrawList()->AddRectFilled(top, ImVec2(top.x + ImGui::GetContentRegionAvail().x, top.y + 24.0f * s),- theme::u32(theme::accent, a), 3.0f * s);+ theme::u32(theme::accent, a), theme::rounding(3.0f * s));} else {flashPalette_.clear();}@@ -1208,7 +1841,7 @@ void App::drawDivider(bool right, const CanvasRect& r) {ImDrawList* dl = ImGui::GetWindowDrawList();const float cx = std::floor(r.x + r.w * 0.5f), cy = r.y + r.h * 0.5f;const ImU32 grip = theme::u32(hovered || active ? theme::accent : theme::textDim, hovered || active ? 1.0f : 0.5f);- dl->AddRectFilled(ImVec2(cx - 1.0f * s, cy - 16.0f * s), ImVec2(cx + 1.0f * s, cy + 16.0f * s), grip, 1.0f * s);+ dl->AddRectFilled(ImVec2(cx - 1.0f * s, cy - 16.0f * s), ImVec2(cx + 1.0f * s, cy + 16.0f * s), grip, theme::rounding(1.0f * s));ImGui::End();}@@ -1457,17 +2090,17 @@ void App::drawShelfItem(int shelf, int index, const std::string& item, bool vertconst ImVec2 a = ImGui::GetItemRectMin(), b = ImGui::GetItemRectMax();ImDrawList* dl = ImGui::GetWindowDrawList();const bool on = found >= 0 && doc_.activeBrush == found && !paintMode_;- if (ImGui::IsItemHovered()) dl->AddRectFilled(a, b, theme::u32(theme::buttonHover, 0.55f), 4.0f * s);+ if (ImGui::IsItemHovered()) dl->AddRectFilled(a, b, theme::u32(theme::buttonHover, 0.55f), theme::rounding(4.0f * s));const float capH = (fontSmall_ ? fontSmall_->FontSize : 12.0f) + 2.0f * s;const float pic = size.y - capH;ImTextureID tex = found >= 0 ? thumbs_.recipe(doc_.brushes[size_t(found)]) : ImTextureID(0);const ImVec2 c((a.x + b.x) * 0.5f, a.y + pic * 0.5f);if (tex) dl->AddImageRounded(tex, ImVec2(c.x - pic * 0.5f, a.y), ImVec2(c.x + pic * 0.5f, a.y + pic), ImVec2(0, 0), ImVec2(1, 1),- IM_COL32_WHITE, 4.0f * s);+ IM_COL32_WHITE, theme::rounding(4.0f * s));else drawBrushIcon(dl, c, pic * 0.36f, int(BrushType::Standard));dl->AddText(fontSmall_, fontSmall_ ? fontSmall_->FontSize : 12.0f, ImVec2(a.x + 2.0f * s, a.y), theme::u32(theme::accent),ICON_LC_SPARKLE);- if (on) dl->AddRect(a, b, theme::u32(theme::accent), 4.0f * s, 0, 2.0f * s);+ if (on) dl->AddRect(a, b, theme::u32(theme::accent), theme::rounding(4.0f * s), 0, 2.0f * s);centredText(dl, fontSmall_, ImVec2(a.x, b.y - capH), b, theme::u32(found < 0 ? theme::textDim : on ? theme::accent : theme::text),elide(fontSmall_ ? fontSmall_ : ImGui::GetFont(), name, size.x).c_str());if (clicked && found >= 0) {@@ -1615,7 +2248,7 @@ bool App::canvasNavButton(const char* id, const char* icon, const char* englishL}const ImVec2 a = ImGui::GetItemRectMin(), b = ImGui::GetItemRectMax();ImDrawList* dl = ImGui::GetWindowDrawList();- dl->AddRectFilled(a, b, theme::u32(active ? theme::accent : hovered ? theme::buttonHover : theme::frame), 4.0f * s);+ dl->AddRectFilled(a, b, theme::u32(active ? theme::accent : hovered ? theme::buttonHover : theme::frame), theme::rounding(4.0f * s));const float capH = (fontTiny_ ? fontTiny_->FontSize : 10.0f) + 2.0f * s;const ImU32 fg = theme::u32(active ? theme::textOnAccent : theme::text);centredText(dl, fontIcons_, a, ImVec2(b.x, b.y - capH + 2.0f * s), fg, icon);@@ -1639,8 +2272,8 @@ bool tileFrame(const char* id, ImVec2 size, ImFont* font, const std::string& capconst float capH = (font ? font->FontSize : 12.0f) + 4.0f * s;pic0 = a;pic1 = ImVec2(b.x, b.y - capH);- dl->AddRectFilled(pic0, pic1, theme::u32(theme::tile), 4.0f * s);- if (hovered) dl->AddRect(pic0, pic1, theme::u32(theme::accent, 0.8f), 4.0f * s, 0, 1.5f * s);+ dl->AddRectFilled(pic0, pic1, theme::u32(theme::tile), theme::rounding(4.0f * s));+ if (hovered) dl->AddRect(pic0, pic1, theme::u32(theme::accent, 0.8f), theme::rounding(4.0f * s), 0, 1.5f * s);centredText(dl, font, ImVec2(a.x, b.y - capH), b, theme::u32(hovered ? theme::text : theme::textDim),elide(font ? font : ImGui::GetFont(), caption, size.x).c_str());ImGui::LogText("%s", caption.c_str());@@ -1677,7 +2310,7 @@ void App::drawBrushTile(const char* id, ImVec2 size) {const float r = (b.x - a.x) * 0.36f;if (tex) {dl->AddImageRounded(tex, ImVec2(a.x + 2 * s, a.y + 2 * s), ImVec2(b.x - 2 * s, b.y - 2 * s), ImVec2(0, 0), ImVec2(1, 1),- IM_COL32_WHITE, 4.0f * s);+ IM_COL32_WHITE, theme::rounding(4.0f * s));} else if (guidesMode_) { // QRemesh Guides (PanelRetopo.cpp)dl->AddCircleFilled(c, r, theme::u32(theme::tile), 32);centredText(dl, fontIcons_, a, b, IM_COL32(255, 196, 64, 255), ICON_LC_SPLINE);@@ -1719,7 +2352,7 @@ void App::drawStrokeTile(const char* id, ImVec2 size) {}break;case StrokeType::DragRect:- dl->AddRect(at(0.22f, 0.26f), at(0.78f, 0.74f), col, 2.0f * s, 0, 1.5f * s);+ dl->AddRect(at(0.22f, 0.26f), at(0.78f, 0.74f), col, theme::rounding(2.0f * s), 0, 1.5f * s);dl->AddLine(at(0.3f, 0.66f), at(0.7f, 0.34f), col, 1.5f * s);dl->AddTriangleFilled(at(0.7f, 0.34f), at(0.6f, 0.36f), at(0.67f, 0.44f), col);break;@@ -1766,7 +2399,7 @@ void App::drawAlphaTile(const char* id, ImVec2 size) {const bool clicked = tileFrame(id, size, fontSmall_, doc_.brushVdm->name, s, a, b);if (ImTextureID tex = thumbs_.vdm(doc_.brushVdm))ImGui::GetWindowDrawList()->AddImageRounded(tex, ImVec2(a.x + 2 * s, a.y + 2 * s), ImVec2(b.x - 2 * s, b.y - 2 * s),- ImVec2(0, 0), ImVec2(1, 1), IM_COL32_WHITE, 4.0f * s);+ ImVec2(0, 0), ImVec2(1, 1), IM_COL32_WHITE, theme::rounding(4.0f * s));if (clicked) openPicker(Picker::Alpha, ImVec2(ImGui::GetItemRectMax().x + 4.0f * s, ImGui::GetItemRectMin().y));ui::HelpText("VDM", nullptr, "The VDM brush's vector displacement map. Click to pick another.", "Left shelf");return;@@ -1776,11 +2409,11 @@ void App::drawAlphaTile(const char* id, ImVec2 size) {ImTextureID tex = thumbs_.alpha(doc_.brushAlpha);if (tex) {dl->AddImageRounded(tex, ImVec2(a.x + 2 * s, a.y + 2 * s), ImVec2(b.x - 2 * s, b.y - 2 * s), ImVec2(0, 0), ImVec2(1, 1),- IM_COL32_WHITE, 4.0f * s);+ IM_COL32_WHITE, theme::rounding(4.0f * s));} else {constexpr int kCells = 26;const float inset = 6.0f * s, cell = (b.x - a.x - 2.0f * inset) / kCells;- dl->AddRectFilled(ImVec2(a.x + inset, a.y + inset), ImVec2(b.x - inset, b.y - inset), IM_COL32(0, 0, 0, 255), 3.0f * s);+ dl->AddRectFilled(ImVec2(a.x + inset, a.y + inset), ImVec2(b.x - inset, b.y - inset), IM_COL32(0, 0, 0, 255), theme::rounding(3.0f * s));for (int y = 0; y < kCells; ++y)for (int x = 0; x < kCells; ++x) {const float u = (float(x) + 0.5f) / kCells * 2.0f - 1.0f, v = 1.0f - (float(y) + 0.5f) / kCells * 2.0f;diff --git a/src/app/Shell.h b/src/app/Shell.hindex 08b9151b..331cf455 100644--- a/src/app/Shell.h+++ b/src/app/Shell.h@@ -28,6 +28,17 @@ struct PaletteDef {const PaletteDef* palettes(int& count); // alphabeticalconst PaletteDef* findPalette(std::string_view id);+// The SculptForge layout's menus, grouped by task (File, Edit, Sculpt, Paint, Mesh, View, Render, Help). Each holds+// whole palettes as its sections, so every palette (and so every item) has exactly one menu.+struct TaskMenuDef {+ const char* id; // "sculpt": the bar button is "Sculpt##menu.sculpt"+ const char* name;+ const char* sections[6]; // palette ids, nullptr-terminated+ const char* titles[6]; // a section's name in this menu, or nullptr for the palette's own+};+const TaskMenuDef* taskMenus(int& count);+int taskMenuOf(std::string_view paletteId); // index into taskMenus, -1 when none+// ui::ActionButton's Tile look: a brush thumbnail with its name (brush actions), or a large icon over a// small caption (right shelf). Returns true when clicked.bool drawShelfTile(App& app, const Action& action, ImVec2 size);diff --git a/src/app/ShellGeometry.cpp b/src/app/ShellGeometry.cppindex 513297d7..934c7553 100644--- a/src/app/ShellGeometry.cpp+++ b/src/app/ShellGeometry.cpp@@ -13,7 +13,54 @@ float trayWidth(float stored, float logicalWindowWidth) {return std::clamp(stored, kTrayMinW, kTrayMaxW);}-ShellGeometry computeShell(const UiLayout& l, float W, float H, float s, float topInset) {+ShellMetrics sculptForgeMetrics(float gap) {+ ShellMetrics m;+ m.titleH = 30;+ m.paletteBarH = 0;+ m.topShelfH = 36;+ m.dividerW = gap > 0.0f ? 0.0f : kDividerW;+ m.gap = gap;+ return m;+}++ShellGeometry computeShell(const UiLayout& l, float W, float H, float s, float topInset, const ShellMetrics& m) {+ if (m.gap > 0.0f) { // tiles: lay out in a window `gap` smaller, then inset every region by half the gap+ const float half = m.gap * 0.5f * s;+ ShellMetrics inner = m;+ inner.gap = 0.0f;+ inner.grow = m.gap;+ UiLayout unmirrored = l; // mirrored at the end, dividers included+ unmirrored.leftHanded = false;+ ShellGeometry g = computeShell(unmirrored, W - 2.0f * half, H - 2.0f * half, s, topInset, inner);+ auto shift = [&](CanvasRect& r) {+ r.x += half;+ r.y += half;+ };+ auto inset = [&](CanvasRect& r) {+ shift(r);+ if (r.w > 0.0f) r.x += half, r.w = std::max(1.0f, r.w - 2.0f * half);+ if (r.h > 0.0f) r.y += half, r.h = std::max(1.0f, r.h - 2.0f * half);+ };+ shift(g.notchBand);+ for (CanvasRect* r : {&g.title, &g.paletteBar, &g.topShelf, &g.leftShelf, &g.rightShelf, &g.bottomShelf, &g.console,+ &g.leftTray, &g.rightTray, &g.canvas})+ inset(*r);+ // The dividers: the gap beside each tray (between the tray and the shelves, or the window edge when closed).+ if (g.shelves) {+ const float top = g.topShelf.y, bottom = g.bottomShelf.y + g.bottomShelf.h;+ const float lx = g.leftTray.w > 0.0f ? g.leftTray.x + g.leftTray.w : 0.0f;+ const float rx = g.rightTray.w > 0.0f ? g.rightTray.x : W;+ const float leftEdge = std::min(g.topShelf.x, g.leftShelf.x), rightEdge = std::max(g.topShelf.x + g.topShelf.w,+ g.rightShelf.x + g.rightShelf.w);+ g.leftDivider = {lx, top, std::max(2.0f * s, leftEdge - lx), bottom - top};+ g.rightDivider = {rightEdge, top, std::max(2.0f * s, rx - rightEdge), bottom - top};+ }+ if (l.leftHanded)+ for (CanvasRect* r : {&g.topShelf, &g.leftShelf, &g.rightShelf, &g.bottomShelf, &g.console, &g.leftDivider,+ &g.rightDivider, &g.leftTray, &g.rightTray, &g.canvas})+ r->x = W - r->x - r->w;+ return g;+ }ShellGeometry g;g.scale = s;const float logicalW = s > 0.0f ? W / s : W;@@ -22,8 +69,8 @@ ShellGeometry computeShell(const UiLayout& l, float W, float H, float s, float tconst float inset = std::clamp(topInset, 0.0f, H * 0.25f);g.notchBand = {0, 0, W, inset};- g.title = {0, inset, W, kTitleH * s};- const float barH = l.paletteBarVisible ? kPaletteBarH * s : 0.0f;+ g.title = {0, inset, W, (m.titleH + m.grow) * s};+ const float barH = l.paletteBarVisible && m.paletteBarH > 0.0f ? (m.paletteBarH + m.grow) * s : 0.0f;g.paletteBar = {0, inset + g.title.h, W, barH};const float top = inset + g.title.h + barH;@@ -31,7 +78,7 @@ ShellGeometry computeShell(const UiLayout& l, float W, float H, float s, float tif (g.shelves) {const float lw = l.leftTrayOpen ? trayWidth(l.leftTrayWidth, logicalW) * s : 0.0f;const float rw = l.rightTrayOpen && !g.narrow ? trayWidth(l.rightTrayWidth, logicalW) * s : 0.0f;- const float dw = kDividerW * s;+ const float dw = m.dividerW * s;g.leftTray = {0, top, lw, H - top};g.leftDivider = {lw, top, dw, H - top};g.rightTray = {W - rw, top, rw, H - top};@@ -46,16 +93,16 @@ ShellGeometry computeShell(const UiLayout& l, float W, float H, float s, float t}const float span = std::max(0.0f, right - left);- const float topH = g.shelves ? kTopShelfH * s : 0.0f;- const float bottomH = g.shelves ? bottomShelfSize(l.shelfTiles).shelfH * s : 0.0f;+ const float topH = g.shelves ? (m.topShelfH + m.grow) * s : 0.0f;+ const float bottomH = g.shelves ? (bottomShelfSize(l.shelfTiles).shelfH + m.grow) * s : 0.0f;g.topShelf = {left, top, span, topH};g.bottomShelf = {left, H - bottomH, span, bottomH};const float consoleH = l.consoleOpen ? std::clamp(l.consoleHeight, kConsoleMinH, kConsoleMaxH) * s : 0.0f;g.console = {left, g.bottomShelf.y - consoleH, span, consoleH};const float y0 = top + topH, y1 = std::max(y0, g.console.y);- const float leftW = g.shelves ? (g.narrow ? kLeftShelfNarrowW : kLeftShelfW) * s : 0.0f;- const float rightW = g.shelves ? kRightShelfW * s : 0.0f;+ const float leftW = g.shelves ? ((g.narrow ? kLeftShelfNarrowW : kLeftShelfW) + m.grow) * s : 0.0f;+ const float rightW = g.shelves ? (kRightShelfW + m.grow) * s : 0.0f;g.leftShelf = {left, y0, leftW, y1 - y0};g.rightShelf = {right - rightW, y0, rightW, y1 - y0};g.canvas = {left + leftW, y0, std::max(1.0f, span - leftW - rightW), std::max(1.0f, y1 - y0)};diff --git a/src/app/ShellGeometry.h b/src/app/ShellGeometry.hindex 65ccb122..4e73ce04 100644--- a/src/app/ShellGeometry.h+++ b/src/app/ShellGeometry.h@@ -44,7 +44,20 @@ constexpr BottomShelfSize bottomShelfSize(int tiles) {// windows 1920 logical px wide or more.float trayWidth(float stored, float logicalWindowWidth);+// The sizes that differ between the ZBrush-style layout (the defaults: shell:: above) and the SculptForge layout,+// and the gap of a tiled look (Preferences > Interface > Look), logical px.+struct ShellMetrics {+ float titleH = shell::kTitleH, paletteBarH = shell::kPaletteBarH, topShelfH = shell::kTopShelfH;+ float dividerW = shell::kDividerW;+ float gap = 0.0f; // tiles: every region is inset so `gap` px of wallpaper shows between them and at the edges+ // (bars and shelves grow by the gap first, so what's inside keeps its size); the dividers+ // become the gaps beside the trays+ float grow = 0.0f; // (internal) added to the bars' and shelves' sizes+};+ShellMetrics sculptForgeMetrics(float gap); // the SculptForge layout: menus in the status bar, a one-row tool shelf+// `topInset` (window px) keeps everything below a camera notch or other unsafe band at the top.-ShellGeometry computeShell(const UiLayout& layout, float width, float height, float scale, float topInset = 0.0f);+ShellGeometry computeShell(const UiLayout& layout, float width, float height, float scale, float topInset = 0.0f,+ const ShellMetrics& metrics = ShellMetrics());} // namespace sfdiff --git a/src/app/Theme.cpp b/src/app/Theme.cppindex 06a66643..97878afe 100644--- a/src/app/Theme.cpp+++ b/src/app/Theme.cpp@@ -2,6 +2,12 @@// SPDX-License-Identifier: GPL-3.0-or-later#include "app/Theme.h"+#include "app/LookSchemes.h"+#include "app/Ui.h"++#include <algorithm>+#include <vector>+namespace sf::theme {void applyStyle() {@@ -82,4 +88,175 @@ void applyStyle() {c[ImGuiCol_ModalWindowDimBg] = rgb(0x000000, 0.45f);}+namespace {++ImVec4* const kTokens[] = {&shellBg, &panelBg, &header, &headerHover, &frame, &frameHover, &button, &buttonHover,+ &buttonPressed, &accent, &accentHover, &toggleOff, &toggleOffHover, &toggleOn, &toggleOnHover,+ &trough, &selection, &selectionActive, &sliderFill, &sliderBar, &checkMark, &checkBorder,+ §ionRule, &text, &textBright, &textOff, &textDim, &textOnAccent, &textHover, &border, &danger,+ &canvasBorder, &tile, &gapBg, &tileBorder, &focusBorder};++// The Classic look's tokens, as Theme.h initialises them (taken before any look changes them).+const std::vector<ImVec4>& classicTokens() {+ static const std::vector<ImVec4> saved = [] {+ std::vector<ImVec4> v;+ for (ImVec4* t : kTokens) v.push_back(*t);+ return v;+ }();+ return saved;+}++ImVec4 mixc(const ImVec4& a, const ImVec4& b, float t, float alpha = 1.0f) {+ return ImVec4(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t, alpha);+}++ImVec4 g_gradCentre(0.215f, 0.215f, 0.222f, 1.0f), g_gradEdge(0.106f, 0.106f, 0.114f, 1.0f);++void syncUiColors() {+ ui::color::accent = u32(accent);+ ui::color::accentHover = u32(accentHover);+ ui::color::text = u32(text);+ ui::color::textDim = u32(textDim);+ ui::color::danger = u32(danger);+ ui::color::panelBg = u32(panelBg);+ ui::color::shellBg = u32(shellBg);+ ui::color::header = u32(header);+ ui::color::border = u32(border);+}++// The tokens of a scheme. Every look reads its colours through these, so a new scheme needs only its Palette.+void setTokens(const looks::Palette& p, looks::LookId id) {+ const ImVec4 crust = rgb(p.crust), mantle = rgb(p.mantle), base = rgb(p.base), s0 = rgb(p.surface0),+ s1 = rgb(p.surface1), s2 = rgb(p.surface2), ov = rgb(p.overlay), sub = rgb(p.subtext), tx = rgb(p.text),+ br = rgb(p.bright), ac = rgb(p.accent);+ const bool phosphor = id == looks::LookId::Phosphor, blueprint = id == looks::LookId::Blueprint;+ gapBg = blueprint ? crust : mixc(crust, rgb(0x000000), p.light ? 0.0f : 0.35f); // the wallpaper: a clear step below the tiles+ shellBg = mantle;+ panelBg = base;+ header = mixc(base, s0, 0.75f);+ headerHover = s1;+ frame = mixc(s0, s1, 0.15f); // slider and check box frames: a clear step above the panels+ frameHover = mixc(s0, s1, 0.6f);+ button = s0;+ buttonHover = s1;+ buttonPressed = s2;+ accent = ac;+ accentHover = mixc(ac, p.light ? rgb(0x000000) : rgb(0xffffff), 0.18f);+ toggleOff = mixc(mantle, s0, 0.6f);+ toggleOffHover = s0;+ toggleOn = s1;+ toggleOnHover = s2;+ trough = mixc(mantle, s0, 0.7f);+ selection = mixc(s0, s1, 0.7f);+ selectionActive = s2;+ sliderFill = ImVec4(ac.x, ac.y, ac.z, phosphor ? 0.16f : 0.13f);+ sliderBar = mixc(ov, ac, 0.35f);+ checkMark = tx;+ checkBorder = s2;+ sectionRule = ImVec4(s1.x, s1.y, s1.z, 0.9f);+ text = tx;+ textBright = br;+ textOff = sub;+ textDim = mixc(ov, sub, 0.25f);+ textOnAccent = p.light ? rgb(0xffffff) : crust;+ textHover = br;+ border = crust;+ danger = rgb(p.red);+ canvasBorder = crust;+ tile = s0;+ tileBorder = blueprint ? mixc(base, ac, 0.38f) : phosphor ? mixc(base, ac, 0.3f) : mixc(s1, s2, 0.55f);+ focusBorder = ac;+ // The 3D view: lightest behind the model, the tiles' shade at the edges (the gaps frame it).+ g_gradCentre = blueprint ? mixc(base, s2, 0.55f) : phosphor ? mixc(base, s1, 0.55f) : mixc(base, s1, 0.85f);+ g_gradEdge = blueprint ? mixc(crust, base, 0.5f) : phosphor ? crust : mixc(mantle, crust, 0.3f);+}++} // namespace++void applyLook(const LookSettings& settings, std::string* status) {+ const std::vector<ImVec4>& classic = classicTokens();+ const looks::LookId id = settings.look > 0 && settings.look < int(looks::LookId::Count) ? looks::LookId(settings.look)+ : looks::LookId::Classic;+ look = LookStyle{};+ look.id = int(id);+ if (id == looks::LookId::Classic) {+ for (size_t i = 0; i < std::size(kTokens); ++i) *kTokens[i] = classic[i];+ g_gradCentre = ImVec4(0.215f, 0.215f, 0.222f, 1.0f);+ g_gradEdge = ImVec4(0.106f, 0.106f, 0.114f, 1.0f);+ applyStyle();+ syncUiColors();+ return;+ }+ looks::Palette palette;+ if (id == looks::LookId::ForgeTerminal) {+ const looks::SchemeInfo* scheme = looks::findScheme(settings.scheme);+ int count = 0;+ palette = (scheme ? scheme : looks::schemes(count))->palette;+ if (settings.matchOmarchy) {+ std::string name, error;+ looks::Palette omarchy;+ if (looks::readOmarchyTheme(omarchy, name, error)) palette = omarchy;+ else if (status) *status = error;+ }+ look.tiled = true;+ look.gap = 6.0f;+ look.roundingScale = 0.0f;+ look.monoLabels = true;+ look.status = LookStyle::Status::Modules;+ look.headers = LookStyle::Headers::Bar;+ } else if (id == looks::LookId::Phosphor) {+ palette = looks::phosphorPalette(settings.amber);+ look.tiled = true;+ look.gap = 5.0f;+ look.roundingScale = 0.0f;+ look.monoLabels = true;+ look.monoAll = true;+ look.status = LookStyle::Status::Terminal;+ look.headers = LookStyle::Headers::Ascii;+ look.upperHeaders = true;+ look.scanlines = look.glow = settings.effects;+ } else {+ palette = looks::blueprintPalette();+ look.tiled = true;+ look.gap = 6.0f;+ look.roundingScale = 0.0f;+ look.monoLabels = true;+ look.status = LookStyle::Status::TitleBlock;+ look.headers = LookStyle::Headers::Grid;+ look.upperHeaders = true;+ }+ for (size_t i = 0; i < std::size(kTokens); ++i) *kTokens[i] = classic[i];+ setTokens(palette, id);+ applyStyle();+ ImGuiStyle& s = ImGui::GetStyle();+ s.WindowRounding = s.ChildRounding = s.PopupRounding = s.FrameRounding = s.GrabRounding = s.TabRounding = 0.0f;+ s.ScrollbarRounding = 0.0f;+ s.ScrollbarSize = 8.0f;+ s.WindowBorderSize = s.PopupBorderSize = 1.0f;+ ImVec4* c = s.Colors;+ const ImVec4 s1 = rgb(palette.surface1), s2 = rgb(palette.surface2);+ c[ImGuiCol_WindowBg] = ImVec4(panelBg.x, panelBg.y, panelBg.z, 0.99f);+ c[ImGuiCol_PopupBg] = ImVec4(panelBg.x, panelBg.y, panelBg.z, 0.99f);+ c[ImGuiCol_Border] = tileBorder;+ c[ImGuiCol_FrameBgActive] = s1;+ c[ImGuiCol_TitleBgActive] = s1;+ c[ImGuiCol_ScrollbarBg] = ImVec4(0, 0, 0, 0);+ c[ImGuiCol_ScrollbarGrab] = s1;+ c[ImGuiCol_ScrollbarGrabHovered] = s2;+ c[ImGuiCol_Separator] = s1;+ c[ImGuiCol_ResizeGrip] = ImVec4(s2.x, s2.y, s2.z, 0.5f);+ c[ImGuiCol_TabSelected] = s1;+ c[ImGuiCol_TabDimmedSelected] = s1;+ c[ImGuiCol_TableBorderStrong] = s1;+ c[ImGuiCol_TableBorderLight] = mixc(rgb(palette.surface0), s1, 0.5f);+ c[ImGuiCol_TableRowBgAlt] = ImVec4(text.x, text.y, text.z, 0.03f);+ c[ImGuiCol_TextSelectedBg] = ImVec4(accent.x, accent.y, accent.z, 0.30f);+ syncUiColors();+}++void lookViewportGradient(ImVec4& centre, ImVec4& edge) {+ centre = g_gradCentre;+ edge = g_gradEdge;+}+} // namespace sf::themediff --git a/src/app/Theme.h b/src/app/Theme.hindex 2574fa69..1d7b7cce 100644--- a/src/app/Theme.h+++ b/src/app/Theme.h@@ -7,54 +7,110 @@#include <imgui.h>+#include <string>+namespace sf::theme {constexpr ImVec4 rgb(unsigned hex, float a = 1.0f) {return ImVec4(float((hex >> 16) & 0xff) / 255.0f, float((hex >> 8) & 0xff) / 255.0f, float(hex & 0xff) / 255.0f, a);}-constexpr ImVec4 shellBg = rgb(0x1b1b1d); // shelves, trays, title strip, around the canvas-constexpr ImVec4 panelBg = rgb(0x222225); // palette drop-downs, tray contents, pop-ups-constexpr ImVec4 header = rgb(0x2b2b2f); // palette and sub-palette headers-constexpr ImVec4 headerHover = rgb(0x37373c);-constexpr ImVec4 frame = rgb(0x28282c); // slider and input frames-constexpr ImVec4 frameHover = rgb(0x323237);-constexpr ImVec4 button = rgb(0x333337);-constexpr ImVec4 buttonHover = rgb(0x414146);-constexpr ImVec4 buttonPressed = rgb(0x4e4e55);+inline ImVec4 shellBg = rgb(0x1b1b1d); // shelves, trays, title strip, around the canvas+inline ImVec4 panelBg = rgb(0x222225); // palette drop-downs, tray contents, pop-ups+inline ImVec4 header = rgb(0x2b2b2f); // palette and sub-palette headers+inline ImVec4 headerHover = rgb(0x37373c);+inline ImVec4 frame = rgb(0x28282c); // slider and input frames+inline ImVec4 frameHover = rgb(0x323237);+inline ImVec4 button = rgb(0x333337);+inline ImVec4 buttonHover = rgb(0x414146);+inline ImVec4 buttonPressed = rgb(0x4e4e55);// The accent marks one thing per group: the current tool or mode (Draw, Sculpt, the brush), plus grabs and checks.-constexpr ImVec4 accent = rgb(0xf0882e);-constexpr ImVec4 accentHover = rgb(0xff9a45);+inline ImVec4 accent = rgb(0xf0882e);+inline ImVec4 accentHover = rgb(0xff9a45);// Options (X, Rgb, Pressure > Strength, Mask, Menus...): off is a dark chip with a readable label (not dim, so it// doesn't look disabled); on is a raised grey with a bright label and a thin accent underline.-constexpr ImVec4 toggleOff = rgb(0x29292e);-constexpr ImVec4 toggleOffHover = rgb(0x36363c);-constexpr ImVec4 toggleOn = rgb(0x4c4c53);-constexpr ImVec4 toggleOnHover = rgb(0x58585f);+inline ImVec4 toggleOff = rgb(0x29292e);+inline ImVec4 toggleOffHover = rgb(0x36363c);+inline ImVec4 toggleOn = rgb(0x4c4c53);+inline ImVec4 toggleOnHover = rgb(0x58585f);// The unselected segments of a mode or choice group (Draw | Move | Scale | Rotate, Zadd | Zsub): a step above the// shelf, so the group reads as one control.-constexpr ImVec4 trough = rgb(0x2c2c31);-constexpr ImVec4 selection = rgb(0x3a3a41); // selected list rows: a lighter neutral row, with a 2 px accent bar on the left-constexpr ImVec4 selectionActive = rgb(0x45454c);-constexpr ImVec4 sliderFill = rgb(0xffffff, 0.09f); // the filled part of a SliderInside-constexpr ImVec4 sliderBar = rgb(0x85858c); // the thin bar along its bottom (the accent only while dragging)-constexpr ImVec4 checkMark = rgb(0xe6e6e8); // check marks and plain slider grabs: neutral, the accent is for modes-constexpr ImVec4 checkBorder = rgb(0x55555c); // the outline of an unchecked box, so it stays visible on panelBg-constexpr ImVec4 sectionRule = rgb(0x3a3a3f, 0.63f); // the hairline under a section header in a palette-constexpr ImVec4 text = rgb(0xd8d8d8);-constexpr ImVec4 textBright = rgb(0xf2f2f2); // labels of options that are on-constexpr ImVec4 textOff = rgb(0xb4b4b9); // labels of options that are off: 6.9:1 on toggleOff-constexpr ImVec4 textDim = rgb(0x8c8c90); // secondary text and disabled labels-constexpr ImVec4 textOnAccent = rgb(0xffffff);-constexpr ImVec4 border = rgb(0x111113); // 1 px between regions-constexpr ImVec4 danger = rgb(0xe5604a); // errors-constexpr ImVec4 canvasBorder = rgb(0x0c0c0e);-constexpr ImVec4 tile = rgb(0x2a2a2e); // thumbnail placeholders-constexpr float markWidth = 2.0f; // the accent underline / side bar, unscaled pixels+inline ImVec4 trough = rgb(0x2c2c31);+inline ImVec4 selection = rgb(0x3a3a41); // selected list rows: a lighter neutral row, with a 2 px accent bar on the left+inline ImVec4 selectionActive = rgb(0x45454c);+inline ImVec4 sliderFill = rgb(0xffffff, 0.09f); // the filled part of a SliderInside+inline ImVec4 sliderBar = rgb(0x85858c); // the thin bar along its bottom (the accent only while dragging)+inline ImVec4 checkMark = rgb(0xe6e6e8); // check marks and plain slider grabs: neutral, the accent is for modes+inline ImVec4 checkBorder = rgb(0x55555c); // the outline of an unchecked box, so it stays visible on panelBg+inline ImVec4 sectionRule = rgb(0x3a3a3f, 0.63f); // the hairline under a section header in a palette+inline ImVec4 text = rgb(0xd8d8d8);+inline ImVec4 textBright = rgb(0xf2f2f2); // labels of options that are on+inline ImVec4 textOff = rgb(0xb4b4b9); // labels of options that are off: 6.9:1 on toggleOff+inline ImVec4 textDim = rgb(0x8c8c90); // secondary text and disabled labels+inline ImVec4 textOnAccent = rgb(0xffffff);+inline ImVec4 textHover = rgb(0xffffff); // hovered or open labels on a header (not on the accent)+inline ImVec4 border = rgb(0x111113); // 1 px between regions+inline ImVec4 danger = rgb(0xe5604a); // errors+inline ImVec4 canvasBorder = rgb(0x0c0c0e);+inline ImVec4 tile = rgb(0x2a2a2e); // thumbnail placeholders+inline float markWidth = 2.0f; // the accent underline / side bar, unscaled pixels++// The SculptForge orange of the cube logo: the brand mark only, the same in every look.+constexpr ImVec4 brand = rgb(0xf0882e);+// Tiled looks (Preferences > Interface > Look): the wallpaper showing in the gaps between the tiles, a tile's thin+// border and the focused tile's border.+inline ImVec4 gapBg = rgb(0x0c0c0e);+inline ImVec4 tileBorder = rgb(0x2a2a2e);+inline ImVec4 focusBorder = rgb(0xf0882e);inline ImU32 u32(const ImVec4& c, float alpha = 1.0f) { return ImGui::ColorConvertFloat4ToU32(ImVec4(c.x, c.y, c.z, c.w * alpha)); }+// How the current look draws the shell, beyond its colours (set by applyLook).+struct LookStyle {+ int id = 0; // looks::LookId+ bool tiled = false; // panels as tiles: gaps, thin borders, the focused one highlighted+ float gap = 0.0f; // between tiles, unscaled px+ float roundingScale = 1.0f; // multiplies the shell's hand-drawn corner radii (0: square corners)+ bool monoLabels = false; // captions, headers, readouts and numbers in the monospace font+ bool monoAll = false; // everything in the monospace font+ enum class Status { Plain, Modules, Terminal, TitleBlock } status = Status::Plain; // the top bar (SculptForge layout)+ enum class Headers { Plain, Bar, Ascii, Grid } headers = Headers::Plain; // palette and section headers+ bool scanlines = false; // Phosphor's effects (off by default): scanlines and a glow, on the chrome only+ bool glow = false;+ bool upperHeaders = false; // palette headers in capitals+};+inline LookStyle look;++// The fonts a look may switch to (App fills them in at start-up); nullptr = keep the default.+struct LookFonts {+ ImFont* mono = nullptr; // 14 px, the numbers in sliders and readouts+ ImFont* monoSmall = nullptr;+ ImFont* monoBold = nullptr;+};+inline LookFonts fonts;++// A corner radius in the current look (square looks return 0).+inline float rounding(float r) { return r * look.roundingScale; }++// The font for numbers and technical readouts: the monospace one in looks that use it, else nullptr.+inline ImFont* numberFont() { return look.monoLabels || look.monoAll ? fonts.mono : nullptr; }+// Sets the colours, rounding and spacing (unscaled; call ImGuiStyle::ScaleAllSizes afterwards).void applyStyle();+// What Preferences > Interface > Look holds (UiPrefs::look).+struct LookSettings {+ int look = 0; // looks::LookId: 0 Classic (the default), Forge Terminal, Phosphor, Blueprint+ std::string scheme = "tokyo_night"; // Forge Terminal's colour scheme (looks::schemes)+ bool matchOmarchy = false; // Forge Terminal: the colours of the current Omarchy theme (Linux, read-only)+ bool amber = false; // Phosphor: amber instead of green+ bool effects = false; // Phosphor: scanlines and glow on the chrome (never on the 3D view)+};++// Sets the look's colour tokens, LookStyle and ImGui style (unscaled, like applyStyle). `status` gets a message+// when Match my Omarchy theme can't read the theme (the scheme is used instead).+void applyLook(const LookSettings& settings, std::string* status = nullptr);+// The 3D view's gradient background in the current look (display sRGB 0-1): behind the model and at the edges.+void lookViewportGradient(ImVec4& centre, ImVec4& edge);+} // namespace sf::themediff --git a/src/app/Ui.cpp b/src/app/Ui.cppindex d9910553..d4948557 100644--- a/src/app/Ui.cpp+++ b/src/app/Ui.cpp@@ -42,6 +42,9 @@ ImVec4 rgba(ImU32 c, float alpha = -1.0f) {float uiScale() { return ImGui::GetFontSize() / 15.0f; }+// A colour of the Classic look, or the current look's token.+ImU32 lookColor(ImU32 classic, const ImVec4& token) { return theme::look.id == 0 ? classic : theme::u32(token); }+bool itemHoveredForHelp() {return ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem);}@@ -218,8 +221,8 @@ float KeycapsAt(ImDrawList* dl, ImVec2 p, const std::string& chord) {if (i) dimText("+");const ImVec2 ts = ImGui::CalcTextSize(keys[i].c_str());const ImVec2 a = p, b(p.x + ts.x + 2 * pad, p.y + h);- dl->AddRectFilled(a, b, IM_COL32(0x2c, 0x2c, 0x30, 0xff), 3.0f * s);- dl->AddRect(a, b, IM_COL32(0x4a, 0x4a, 0x50, 0xff), 3.0f * s);+ dl->AddRectFilled(a, b, lookColor(IM_COL32(0x2c, 0x2c, 0x30, 0xff), theme::frame), theme::rounding(3.0f * s));+ dl->AddRect(a, b, lookColor(IM_COL32(0x4a, 0x4a, 0x50, 0xff), theme::tileBorder), theme::rounding(3.0f * s));dl->AddText(ImVec2(a.x + pad, a.y + 1.0f * s), color::accent, keys[i].c_str());p.x = b.x;}@@ -355,6 +358,14 @@ bool ActionButton(App& app, const char* actionId, ImVec2 size, Look look) {bool SliderInside(const char* id, float* v, float lo, float hi, const char* format, ImGuiSliderFlags flags) {const float w = ImGui::CalcItemWidth(), h = ImGui::GetFrameHeight();+ // Looks with technical numbers draw the label in the monospace font, padded to the same frame height.+ ImFont* numbers = theme::numberFont();+ const float outerSize = ImGui::GetFontSize();+ if (numbers) {+ ImGui::PushFont(numbers);+ const ImVec2 pad = ImGui::GetStyle().FramePadding;+ ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(pad.x, pad.y + (outerSize - ImGui::GetFontSize()) * 0.5f));+ }const ImVec2 p = ImGui::GetCursorScreenPos();ImDrawList* dl = ImGui::GetWindowDrawList();// Frame and fill go underneath the slider (which draws a transparent frame on top).@@ -369,6 +380,10 @@ bool SliderInside(const char* id, float* v, float lo, float hi, const char* formconst bool changed = ImGui::SliderFloat(id, v, lo, hi, format ? tr(format) : format, flags);const bool active = ImGui::IsItemActive();ImGui::PopStyleColor(5);+ if (numbers) {+ ImGui::PopStyleVar();+ ImGui::PopFont();+ }dl->ChannelsSetCurrent(0);float t = 0.0f;if (hi > lo) {@@ -424,7 +439,7 @@ void DrawHelp(App& app) {ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 6.0f * s);ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 1.0f);ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(4.0f * s, 4.0f * s));- ImGui::PushStyleColor(ImGuiCol_WindowBg, rgba(IM_COL32(0x18, 0x18, 0x1a, 0xff), std::clamp(prefs.helpOpacity, 0.3f, 1.0f)));+ ImGui::PushStyleColor(ImGuiCol_WindowBg, rgba(lookColor(IM_COL32(0x18, 0x18, 0x1a, 0xff), theme::shellBg), std::clamp(prefs.helpOpacity, 0.3f, 1.0f)));ImGui::PushStyleColor(ImGuiCol_Border, rgba(color::accent, 0.6f));const ImGuiWindowFlags flags = ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoInputs |ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoFocusOnAppearing |@@ -447,12 +462,12 @@ void DrawHelp(App& app) {{const ImVec2 a = ImGui::GetCursorScreenPos();dl->AddLine(ImVec2(a.x, a.y + 1.0f * s), ImVec2(a.x + ImGui::GetContentRegionAvail().x, a.y + 1.0f * s),- IM_COL32(0x34, 0x34, 0x38, 0xff));+ lookColor(IM_COL32(0x34, 0x34, 0x38, 0xff), theme::sectionRule));ImGui::Dummy(ImVec2(0, 3.0f * s));}ImGui::PushTextWrapPos(0.0f);if (!alternate) {- ImGui::PushStyleColor(ImGuiCol_Text, rgba(IM_COL32(0xc8, 0xc8, 0xc8, 0xff)));+ ImGui::PushStyleColor(ImGuiCol_Text, rgba(lookColor(IM_COL32(0xc8, 0xc8, 0xc8, 0xff), theme::text)));ImGui::TextUnformatted(r.description.empty() ? tr("No description yet.") : r.description.c_str());ImGui::PopStyleColor();if (r.hasCommand && !r.params.empty()) {@@ -475,7 +490,7 @@ void DrawHelp(App& app) {ImGui::SameLine();ImGui::TextColored(rgba(color::textDim), "%s%s", typeName(p.type), p.required ? ", required" : "");ImGui::Indent(10.0f * s);- ImGui::PushStyleColor(ImGuiCol_Text, rgba(IM_COL32(0xc8, 0xc8, 0xc8, 0xff)));+ ImGui::PushStyleColor(ImGuiCol_Text, rgba(lookColor(IM_COL32(0xc8, 0xc8, 0xc8, 0xff), theme::text)));ImGui::TextUnformatted(p.description.c_str());ImGui::PopStyleColor();ImGui::Unindent(10.0f * s);diff --git a/src/app/Ui.h b/src/app/Ui.hindex 360053b0..651d72de 100644--- a/src/app/Ui.h+++ b/src/app/Ui.h@@ -72,15 +72,15 @@ const std::string& HelpShown();// Theme tokens shared by the help, palette and console (ui-spec section 10).namespace color {-inline constexpr ImU32 accent = IM_COL32(0xf0, 0x88, 0x2e, 0xff);-inline constexpr ImU32 accentHover = IM_COL32(0xff, 0x9a, 0x45, 0xff);-inline constexpr ImU32 text = IM_COL32(0xd8, 0xd8, 0xd8, 0xff);-inline constexpr ImU32 textDim = IM_COL32(0x8c, 0x8c, 0x90, 0xff);-inline constexpr ImU32 danger = IM_COL32(0xe5, 0x60, 0x4a, 0xff);-inline constexpr ImU32 panelBg = IM_COL32(0x22, 0x22, 0x25, 0xff);-inline constexpr ImU32 shellBg = IM_COL32(0x1b, 0x1b, 0x1d, 0xff);-inline constexpr ImU32 header = IM_COL32(0x2b, 0x2b, 0x2f, 0xff);-inline constexpr ImU32 border = IM_COL32(0x11, 0x11, 0x13, 0xff);+inline ImU32 accent = IM_COL32(0xf0, 0x88, 0x2e, 0xff);+inline ImU32 accentHover = IM_COL32(0xff, 0x9a, 0x45, 0xff);+inline ImU32 text = IM_COL32(0xd8, 0xd8, 0xd8, 0xff);+inline ImU32 textDim = IM_COL32(0x8c, 0x8c, 0x90, 0xff);+inline ImU32 danger = IM_COL32(0xe5, 0x60, 0x4a, 0xff);+inline ImU32 panelBg = IM_COL32(0x22, 0x22, 0x25, 0xff);+inline ImU32 shellBg = IM_COL32(0x1b, 0x1b, 0x1d, 0xff);+inline ImU32 header = IM_COL32(0x2b, 0x2b, 0x2f, 0xff);+inline ImU32 border = IM_COL32(0x11, 0x11, 0x13, 0xff);} // namespace color} // namespace sf::uidiff --git a/src/app/UiLayout.cpp b/src/app/UiLayout.cppindex 6cda092e..3148a595 100644--- a/src/app/UiLayout.cpp+++ b/src/app/UiLayout.cpp@@ -48,6 +48,25 @@ UiLayout standardLayout() {return l;}+UiLayout standardLayout(int shellLayout) {+ UiLayout l = standardLayout();+ if (shellLayout != 1) return l;+ // The SculptForge layout: one tool row (the mode, the transform tools, add / subtract, the two sliders,+ // dynamic topology, symmetry). Library, Brush Lab, Front, the pressure options and the triangle counts moved to+ // the menus (Sculpt > Draw) and the status bar.+ l.topShelf = {"draw.sculpt", "draw.paint", "sep",+ "tool.draw", "tool.move", "tool.scale", "tool.rotate", "sep",+ "draw.zadd", "draw.zsub", "draw.rgb", "draw.paint_vertex", "draw.paint_texture",+ "draw.new_texture", "sep", "widget.draw_size", "widget.strength", "sep",+ "draw.dynamic", "widget.dyntopo_detail", "sep",+ "transform.symmetry_x", "transform.symmetry_y", "transform.symmetry_z", "transform.symmetry_radial"};+ 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"};+ return l;+}+Json toJson(const UiLayout& l) {Json j = Json::object();j.set("version", double(l.version));diff --git a/src/app/UiLayout.h b/src/app/UiLayout.hindex 423bb217..467f33a2 100644--- a/src/app/UiLayout.h+++ b/src/app/UiLayout.h@@ -39,6 +39,7 @@ struct UiLayout {};UiLayout standardLayout(); // the built-in default+UiLayout standardLayout(int shellLayout); // 0 the ZBrush-style layout (the same), 1 the SculptForge layoutJson toJson(const UiLayout& layout);// Unknown ids are dropped, not fatal; false only for unreadable JSON.bool fromJson(const Json& j, UiLayout& layout, std::string& error);diff --git a/src/app/UiTest.cpp b/src/app/UiTest.cppindex 3b48ad56..e202b1c7 100644--- a/src/app/UiTest.cpp+++ b/src/app/UiTest.cpp@@ -189,6 +189,7 @@// spacemouse_button N press and release button N (1 = left side button, 2 = right)// spacemouse_unplug unplug it// expect_value spacemouse_connected (1 when the app opened it), spacemouse_moving (1 while it moves the view)+// expect_value look (0 Classic, 1 Forge Terminal, 2 Phosphor, 3 Blueprint), shell_layout (0 ZBrush-style, 1 SculptForge)#include "app/App.h"#ifndef SDL_PEN_INPUT_IN_PROXIMITY@@ -456,6 +457,8 @@ double Demo::query(const std::string& name, bool& known) const {if (name == "quickmenu_open") return app_.quickMenu_.open ? 1.0 : 0.0;if (name == "right_click_menu") return app_.uiPrefs_.rightClickQuickMenu ? 1.0 : 0.0;if (name == "space_camera") return app_.uiPrefs_.spaceCamera ? 1.0 : 0.0;+ if (name == "look") return double(app_.uiPrefs_.look.look); // 0 Classic, 1 Forge Terminal, 2 Phosphor, 3 Blueprint+ if (name == "shell_layout") return double(app_.uiPrefs_.shellLayout); // 0 ZBrush-style, 1 SculptForgeif (name == "air_strokes") return app_.uiPrefs_.airStrokes ? 1.0 : 0.0;if (name == "space_held") return app_.spaceHeld_ ? 1.0 : 0.0;if (name == "radial_open") return app_.radial_.menu >= 0 ? 1.0 : 0.0;diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cppindex 30fb1f8e..8c34a7d4 100644--- a/src/render/Renderer.cpp+++ b/src/render/Renderer.cpp@@ -620,9 +620,11 @@ out vec4 fragColor;// Neutral charcoal, lightest a little above the middle (behind the model) and falling off in a soft// radial vignette down to the shade of the shelves around it, so the model reads against it without a// coloured cast and the canvas meets the shell without a darker band. A little noise hides banding.+uniform vec3 uCentre; // RenderSettings::gradientCentre: vec3(0.215, 0.215, 0.222) in the Classic look+uniform vec3 uEdge; // gradientEdge: the shell's shade (Theme shellBg #1b1b1d), so there's no step at the seamsvoid main() {- vec3 centre = vec3(0.215, 0.215, 0.222);- vec3 edge = vec3(0.106, 0.106, 0.114); // the shell's shade (Theme shellBg #1b1b1d): no step at the seams+ vec3 centre = uCentre;+ vec3 edge = uEdge;float d = length((vUv - vec2(0.5, 0.56)) * vec2(1.0, 1.15));float t = smoothstep(0.05, 0.85, d);vec3 c = mix(centre, edge, t);@@ -2683,6 +2685,8 @@ void Renderer::draw(const Camera& camera, int targetWidth, int targetHeight, con}} else if (!thumbnailPass_ && settings.gradientBackground) {gl::UseProgram(bgProgram_);+ gl::Uniform3fv(gl::GetUniformLocation(bgProgram_, "uCentre"), 1, glm::value_ptr(settings.gradientCentre));+ gl::Uniform3fv(gl::GetUniformLocation(bgProgram_, "uEdge"), 1, glm::value_ptr(settings.gradientEdge));gl::DrawArrays(GL_TRIANGLES, 0, 3);}diff --git a/src/render/Renderer.h b/src/render/Renderer.hindex cd271e02..61b4dc5e 100644--- a/src/render/Renderer.h+++ b/src/render/Renderer.h@@ -40,6 +40,10 @@ struct RenderSettings {// The view's background: the charcoal radial gradient (default) or one flat display (sRGB) colour (#21).bool gradientBackground = true;glm::vec3 backgroundColor{0.165f, 0.165f, 0.173f};+ // The gradient's colours (display sRGB): behind the model and at the edges. The interface look sets them+ // (Preferences > Interface > Look); these are the Classic look's charcoal.+ glm::vec3 gradientCentre{0.215f, 0.215f, 0.222f};+ glm::vec3 gradientEdge{0.106f, 0.106f, 0.114f};// Micro-displacement levels (render/MicroRenderer.h): the most triangles a frame draws for them (their level// of detail drops to fit; a hardware profile may set it), and the micro edge length to aim for on screen.size_t renderTriangleBudget = 0; // 0 = TierConfig::activeTriangleBudget (core/TierConfig.h)diff --git a/tests/test_looks.cpp b/tests/test_looks.cppnew file mode 100644index 00000000..f77366d9--- /dev/null+++ b/tests/test_looks.cpp@@ -0,0 +1,147 @@+// SculptForge - open source digital sculpting+// SPDX-License-Identifier: GPL-3.0-or-later+//+// The interface looks (app/LookSchemes.h): the scheme table, reading an Omarchy theme's colours, and the SculptForge+// layout's tiled geometry (app/ShellGeometry.h: gaps between every region, dividers in the gaps beside the trays).+#include "TestHarness.h"++#include "app/LookSchemes.h"+#include "app/ShellGeometry.h"++#include <cmath>+#include <set>+#include <string>+#include <vector>++using namespace sf;++namespace {++bool near(float a, float b) { return std::abs(a - b) < 0.01f; }++bool overlaps(const CanvasRect& a, const CanvasRect& b) {+ return a.w > 0 && a.h > 0 && b.w > 0 && b.h > 0 && a.x < b.x + b.w - 0.01f && b.x < a.x + a.w - 0.01f && a.y < b.y + b.h - 0.01f &&+ b.y < a.y + a.h - 0.01f;+}++} // namespace++TEST(looks_keys_round_trip) {+ for (int i = 0; i < int(looks::LookId::Count); ++i) CHECK(looks::lookFromKey(looks::lookKey(looks::LookId(i))) == looks::LookId(i));+ CHECK(looks::lookFromKey("nonsense") == looks::LookId::Classic);+ CHECK(std::string(looks::lookName(looks::LookId::ForgeTerminal)) == "Forge Terminal");+}++TEST(looks_schemes_complete_and_readable) {+ int count = 0;+ const looks::SchemeInfo* list = looks::schemes(count);+ CHECK(count == 7);+ CHECK(std::string(list[0].key) == "tokyo_night"); // the default comes first+ std::set<std::string> keys;+ auto lum = [](unsigned c) { return 0.2126f * float((c >> 16) & 0xff) + 0.7152f * float((c >> 8) & 0xff) + 0.0722f * float(c & 0xff); };+ for (int i = 0; i < count; ++i) {+ keys.insert(list[i].key);+ CHECK(looks::findScheme(list[i].key) == &list[i]);+ CHECK(list[i].license && *list[i].license);+ const looks::Palette& p = list[i].palette;+ // Darkest to brightest, and text well above the panels.+ CHECK(lum(p.crust) <= lum(p.mantle) + 0.5f);+ CHECK(lum(p.mantle) <= lum(p.base) + 0.5f);+ CHECK(lum(p.base) < lum(p.surface0));+ CHECK(lum(p.text) - lum(p.base) > 120.0f);+ CHECK(lum(p.accent) - lum(p.base) > 70.0f);+ }+ CHECK(keys.size() == size_t(count));+ CHECK(looks::findScheme("solarized") == nullptr);+}++TEST(looks_parse_hex) {+ unsigned v = 0;+ CHECK(looks::parseHex("#7aa2f7", v) && v == 0x7aa2f7);+ CHECK(looks::parseHex("1A1B26", v) && v == 0x1a1b26);+ CHECK(looks::parseHex("#1a1b26ff", v) && v == 0x1a1b26);+ CHECK(!looks::parseHex("#12345", v));+ CHECK(!looks::parseHex("#zzzzzz", v));+}++TEST(looks_omarchy_colors_toml) {+ // An Omarchy theme's colors.toml (Tokyo Night), as Omarchy writes it.+ const std::string colors = "mode = \"dark\"\n\naccent = \"#7aa2f7\"\nselection = \"#292e42\"\nmuted = \"#414868\"\n\n"+ "background = \"#1a1b26\"\ndark_background = \"#13141c\"\ndarker_background = \"#0e0e14\"\n"+ "lighter_background = \"#24283b\"\n\nforeground = \"#a9b1d6\"\ndark_foreground = \"#565f89\"\n"+ "bright_foreground = \"#c0caf5\"\n\nred = \"#f7768e\"\ngreen = \"#9ece6a\"\nyellow = \"#e0af68\"\n"+ "magenta = \"#ad8ee6\"\n";+ looks::Palette p;+ CHECK(looks::paletteFromOmarchy(colors, "", p));+ CHECK(p.base == 0x1a1b26);+ CHECK(p.mantle == 0x13141c);+ CHECK(p.crust == 0x0e0e14);+ CHECK(p.surface0 == 0x24283b);+ CHECK(p.surface1 == 0x292e42);+ CHECK(p.accent == 0x7aa2f7);+ CHECK(p.text == 0xa9b1d6);+ CHECK(p.bright == 0xc0caf5);+ CHECK(p.red == 0xf7768e);+ CHECK(!p.light);+}++TEST(looks_omarchy_alacritty_fallback) {+ // An older theme with only alacritty.toml: the rest is derived from its background and foreground.+ const std::string alacritty = "[colors.primary]\nbackground = \"#faf4ed\"\nforeground = \"#575279\"\n\n"+ "[colors.normal]\nblack = '#f2e9e1'\nred = \"#b4637a\"\nblue = \"#56949f\"\n";+ looks::Palette p;+ CHECK(looks::paletteFromOmarchy("", alacritty, p));+ CHECK(p.base == 0xfaf4ed);+ CHECK(p.text == 0x575279);+ CHECK(p.accent == 0x56949f);+ CHECK(p.red == 0xb4637a);+ CHECK(p.light); // a light theme: its "darker" backgrounds get lighter, not darker+ looks::Palette none;+ CHECK(!looks::paletteFromOmarchy("accent = \"#ffffff\"\n", "", none));+}++TEST(looks_tiled_geometry_has_gaps) {+ const float gap = 6.0f;+ const ShellGeometry g = computeShell(standardLayout(1), 1600, 960, 1.0f, 0.0f, sculptForgeMetrics(gap));+ // The status bar holds the menus: no palette bar; the tool shelf is one row.+ CHECK(near(g.paletteBar.h, 0));+ CHECK(near(g.title.y, gap));+ CHECK(near(g.title.h, 30)); // the bars and shelves grow by the gap: what is inside keeps its size+ CHECK(near(g.topShelf.h, 36));+ CHECK(near(g.leftShelf.w, 88));+ CHECK(near(g.bottomShelf.h, 78));+ const std::vector<const CanvasRect*> tiles = {&g.title, &g.topShelf, &g.leftShelf, &g.rightShelf, &g.bottomShelf, &g.rightTray, &g.canvas};+ for (size_t i = 0; i < tiles.size(); ++i) {+ const CanvasRect& r = *tiles[i];+ CHECK(r.x >= gap - 0.01f && r.y >= gap - 0.01f && r.x + r.w <= 1600 - gap + 0.01f && r.y + r.h <= 960 - gap + 0.01f);+ for (size_t k = i + 1; k < tiles.size(); ++k) CHECK(!overlaps(r, *tiles[k]));+ }+ // Exactly one gap between neighbours.+ CHECK(near(g.canvas.x - (g.leftShelf.x + g.leftShelf.w), gap));+ CHECK(near(g.rightShelf.x - (g.canvas.x + g.canvas.w), gap));+ CHECK(near(g.canvas.y - (g.topShelf.y + g.topShelf.h), gap));+ CHECK(near(g.bottomShelf.y - (g.canvas.y + g.canvas.h), gap));+ CHECK(near(g.rightTray.x - (g.rightShelf.x + g.rightShelf.w), gap));+ // The right divider is that gap, the full height of the shelves.+ CHECK(near(g.rightDivider.x, g.rightShelf.x + g.rightShelf.w));+ CHECK(near(g.rightDivider.w, gap));+ CHECK(near(g.rightDivider.y, g.topShelf.y));+}++TEST(looks_tiled_geometry_left_handed) {+ UiLayout l = standardLayout(1);+ l.leftHanded = true;+ const ShellGeometry g = computeShell(l, 1600, 960, 1.0f, 0.0f, sculptForgeMetrics(6.0f));+ CHECK(near(g.rightTray.x, 6)); // the tray moved to the left edge+ CHECK(g.canvas.x > g.rightTray.x + g.rightTray.w);+ CHECK(!overlaps(g.canvas, g.rightTray));+ CHECK(near(g.rightDivider.x + g.rightDivider.w, g.rightShelf.x)); // after the mirror, still the gap beside the tray+}++TEST(looks_standard_layouts) {+ const UiLayout zb = standardLayout(0), sf = standardLayout(1);+ CHECK(zb.topShelf == standardLayout().topShelf); // the ZBrush-style layout is the old standard one+ CHECK(sf.topShelf != zb.topShelf);+ for (const std::string& id : sf.topShelf) CHECK(id != "row"); // one row+ CHECK(sf.bottomShelf == zb.bottomShelf);+}diff --git a/tests/ui/looks.sfui b/tests/ui/looks.sfuinew file mode 100644index 00000000..ffbff888--- /dev/null+++ b/tests/ui/looks.sfui@@ -0,0 +1,115 @@+# The interface looks and the SculptForge layout (Preferences > Interface > Look): the task menus hold every palette+# as a section, the ZBrush-style layout stays one setting away, and switching looks keeps everything working.+run new_sphere subdivisions=3+expect_value look == 0+expect_value shell_layout == 0+expect "Tool##palette.tool" # the default: Classic, ZBrush-style palette bar++# Forge Terminal brings the SculptForge layout: the menus in the status bar, no palette bar, a one-row shelf.+run ui_look look=forge scheme=nord+wait 0.2+expect_value look == 1+expect_value shell_layout == 1+expect "Sculpt##menu.sculpt"+expect_not "Tool##palette.tool"+expect_not "Library##ui.lightbox" # moved off the shelf (View > Display, F3)+expect "Clay##brush.clay"+expect "##drawsize"+expect "SubTools/Append" # the Tool palette stays in the right tray+shot forge++# Every palette is a section of one menu.+click "File##menu.file"+click "File##section.file"+expect "File/##totray"+click "Script##section.script"+expect "Script/##totray"+key escape+click "Edit##menu.edit"+click "Edit##section.edit"+expect "Edit/##totray"+click "Preferences##section.preferences"+expect "Preferences/##totray"+key escape+click "Sculpt##menu.sculpt"+click "Brush##section.brush"+expect "Brush/##totray"+click "Draw & Tablet##section.draw"+expect "Draw/##totray"+click "Alpha##section.alpha"+expect "Alpha/##totray"+click "Symmetry & Gizmo##section.transform"+expect "Transform/##totray"+click "Stroke##section.stroke"+expect "Stroke/##totray"+shot sculpt-menu+key escape+click "Paint##menu.paint"+expect "Color/##totray"+key escape+click "Mesh##menu.mesh" # Tool is in the tray, so the menu opens on Generate+expect "Generate/##totray"+key escape+click "View##menu.view"+expect "Render/##totray"+key escape+click "Render##menu.render"+click "Materials##section.material"+expect "Material/##totray"+click "Gaussian Splats##section.splats"+expect "Splats/##totray"+key escape+click "Help##menu.help"+expect "Help/##totray"+key escape++# A section pinned from its menu goes to the tray, as from the palette bar.+click "Sculpt##menu.sculpt"+click "Stroke##section.stroke"+click "Stroke/##totray"+expect_value right_tray == 2 # Tool and Stroke+click "Sculpt##menu.sculpt"+click "Brush##section.brush"+expect "Brush/##totray"+key escape++# The other looks and colour schemes.+run ui_look look=phosphor phosphor=amber effects=true+wait 0.2+expect_value look == 2+expect "Sculpt##menu.sculpt"+shot phosphor+run ui_look look=blueprint+wait 0.2+expect_value look == 3+shot blueprint+run ui_look look=forge scheme=everforest+wait 0.2+run_fails ui_look scheme=solarized+run_fails ui_look look=neon+run_fails ui_look layout=tabs++# The look cards in Preferences > Interface.+click "Edit##menu.edit"+click "Preferences##section.preferences"+click "Interface##preferences.interface"+click "Blueprint##look.blueprint"+wait 0.2+expect_value look == 3+key escape++# The ZBrush-style layout is one setting away and works with any look.+run ui_look layout=zbrush+wait 0.2+expect_value shell_layout == 0+expect "Tool##palette.tool"+expect "Library##ui.lightbox"+expect_not "Sculpt##menu.sculpt"+click "Stroke##palette.stroke"+expect "Stroke/##totray"+key escape+shot blueprint-zbrush-layout+run ui_look look=classic+wait 0.2+expect_value look == 0+expect "Tool##palette.tool"diff --git a/tools/looks/shots.sfui b/tools/looks/shots.sfuinew file mode 100644index 00000000..4028d8f8--- /dev/null+++ b/tools/looks/shots.sfui@@ -0,0 +1,119 @@+# Screenshots of the interface looks (Preferences > Interface > Look) for choosing the default. Run from the+# source folder, at each size:+# build/sculptforge --ui-test tools/looks/shots.sfui --ui-out build/look-shots/1600 --size 1600x960+# build/sculptforge --ui-test tools/looks/shots.sfui --ui-out build/look-shots/2400 --size 2400x1350+# A realistic state: the lion head, a brush active, the Parts palette open in the tray, the pointer on the model.+run open path=assets/demo/lion-head.glb+wait_idle 20++run ui_look look=classic layout=zbrush+run open path=assets/demo/lion-head.glb+wait_idle 20+click "Clay##brush.clay"+hover_model 0.52 0.42+wait 0.3+shot classic-zbrush-layout++run ui_look look=forge scheme=tokyo_night+run open path=assets/demo/lion-head.glb+wait_idle 20+click "Clay##brush.clay"+hover_model 0.52 0.42+wait 0.3+shot forge-tokyo-night+click "Sculpt##menu.sculpt"+wait 0.3+shot forge-tokyo-night-menu+key escape++run ui_look scheme=catppuccin_mocha+run open path=assets/demo/lion-head.glb+wait_idle 20+click "Clay##brush.clay"+hover_model 0.52 0.42+wait 0.3+shot forge-catppuccin-mocha+run ui_look scheme=gruvbox_dark+run open path=assets/demo/lion-head.glb+wait_idle 20+click "Clay##brush.clay"+hover_model 0.52 0.42+wait 0.3+shot forge-gruvbox-dark+run ui_look scheme=nord+run open path=assets/demo/lion-head.glb+wait_idle 20+click "Clay##brush.clay"+hover_model 0.52 0.42+wait 0.3+shot forge-nord+run ui_look scheme=rose_pine+run open path=assets/demo/lion-head.glb+wait_idle 20+click "Clay##brush.clay"+hover_model 0.52 0.42+wait 0.3+shot forge-rose-pine+run ui_look scheme=kanagawa+run open path=assets/demo/lion-head.glb+wait_idle 20+click "Clay##brush.clay"+hover_model 0.52 0.42+wait 0.3+shot forge-kanagawa+run ui_look scheme=everforest+run open path=assets/demo/lion-head.glb+wait_idle 20+click "Clay##brush.clay"+hover_model 0.52 0.42+wait 0.3+shot forge-everforest++run ui_look look=phosphor phosphor=green effects=false+run open path=assets/demo/lion-head.glb+wait_idle 20+click "Clay##brush.clay"+hover_model 0.52 0.42+wait 0.3+shot phosphor-green+click "Edit##menu.edit"+click "Preferences##section.preferences"+click "Interface##preferences.interface"+wait 0.3+shot phosphor-green-menu+key escape+run ui_look phosphor=green effects=true+run open path=assets/demo/lion-head.glb+wait_idle 20+click "Clay##brush.clay"+hover_model 0.52 0.42+wait 0.3+shot phosphor-green-effects+run ui_look phosphor=amber effects=false+run open path=assets/demo/lion-head.glb+wait_idle 20+click "Clay##brush.clay"+hover_model 0.52 0.42+wait 0.3+shot phosphor-amber++run ui_look look=blueprint+run open path=assets/demo/lion-head.glb+wait_idle 20+click "Clay##brush.clay"+hover_model 0.52 0.42+wait 0.3+shot blueprint+click "Render##menu.render"+wait_idle 20+wait 0.3+shot blueprint-menu+key escape++run ui_look look=classic layout=sculptforge+run open path=assets/demo/lion-head.glb+wait_idle 20+click "Clay##brush.clay"+hover_model 0.52 0.42+wait 0.3+shot classic-sculptforge-layout