Font previews in the Type bar; Ctrl+Z while typing judged and pinned (13.6)

This commit is contained in:
ZacharyZhang-NY committed 2026-10-01 14:26:36 -04:00
1 parent 93a4c62b8f
commit 9ed7c20681
10 files changed
+278 -10

No files matched your search

+2 -2
View File
@@ -85,12 +85,10 @@ public:
// Where the project lives on disk, once opened or saved.
const std::optional<QString> &projectPath() const { return m_projectPath; }
void setProjectPath(std::optional<QString> path);
bool canStartProjectOperation() const;
// `ready` runs at once, or when the session allows.
void waitForFileRequest(std::function<void()> ready);
void waitForProjectAccess(std::function<void()> ready);
void selectLayer(std::optional<QUuid> id);
void selectTool(NavigationTool value);
// Tab: the current tool's next mode.
@@ -432,6 +430,8 @@ private:
mutable std::map<QUuid, ShapePreview> m_shapeTransformPreviewCache;
std::optional<TextDraft> m_textDraft;
LayerTextStyle m_textDefaults;
// The text's style before the font menu previewed faces.
std::optional<LayerTextStyle> m_fontPreviewOriginal;
std::optional<QPointF> m_cloneSource;
CloneSettings m_cloneSettings;
// The offset aligned strokes keep, fixed as a stroke begins.
+6
View File
@@ -17,6 +17,12 @@ public:
bool recolorText(QUuid id, const PaletteColor &color);
LayerTextStyle currentTextStyle() const;
void changeTextStyle(const std::function<void(LayerTextStyle &)> &change);
// The open font menu tries the hovered face on text.
void previewFont(const QString &name);
// Chosen: the text stays as it shows.
void keepFontPreview();
// Closed without a choice: the text goes back.
void endFontPreview();
// A text layer's name: its first words on one line.
static QString layerName(const QString &content);
// Point text's size: what it measures, plus padding.
+33
View File
@@ -255,6 +255,39 @@ LayerTextStyle EditorSession::currentTextStyle() const
return active && active->liveText() ? active->liveText()->style : m_textDefaults;
}
// Only text being edited; a selected layer is not opened.
void EditorSession::previewFont(const QString &name)
{
if (!m_textDraft)
return;
TextDraft draft = *m_textDraft;
if (!m_fontPreviewOriginal)
m_fontPreviewOriginal = draft.style;
LayerTextStyle style = *m_fontPreviewOriginal;
style.setFont(name, draft.selection);
if (!style.isValid() || style == draft.style)
return;
draft.style = style;
setTextDraft(draft);
}
void EditorSession::keepFontPreview()
{
m_fontPreviewOriginal.reset();
}
void EditorSession::endFontPreview()
{
if (!m_fontPreviewOriginal)
return;
const LayerTextStyle original = *std::exchange(m_fontPreviewOriginal, std::nullopt);
if (m_textDraft && m_textDraft->style != original) {
TextDraft draft = *m_textDraft;
draft.style = original;
setTextDraft(draft);
}
}
void EditorSession::changeTextStyle(const std::function<void(LayerTextStyle &)> &change)
{
const std::optional<ImageLayer> active = activeLayer();