Export JPEG and Canvas Size take the app's colour picker; a panel opens over a modal sheet (13.4a)

This commit is contained in:
ZacharyZhang-NY committed 2026-10-01 07:16:16 -04:00
1 parent 0b7eb6cb6f
commit bc49b722eb
23 files changed
+470 -134

No files matched your search

+5
View File
@@ -28,6 +28,11 @@ public:
void openEffectColorPicker(LayerEffectKind kind);
// The effect follows the picker's working colour.
void previewEffectColor();
// The picker on a dialog's colour, which hears each change.
void openDialogColorPicker(const QString &title, const PaletteColor &color, std::function<void(const PaletteColor &)> change);
// A dialog covers the canvas: nothing to sample.
bool pickingForDialog() const;
void previewDialogColor() const;
// The open text draft previews the picker's working colour.
void previewTextColor();
// Paints the open text's selected letters, or all of it.
+27
View File
@@ -109,6 +109,8 @@ QString ColorPickerTarget::title() const
return QStringLiteral("Color Picker (Vignette Color)");
if (kind == Kind::dither)
return light ? QStringLiteral("Color Picker (Dither Light Color)") : QStringLiteral("Color Picker (Dither Dark Color)");
if (kind == Kind::dialog)
return QStringLiteral("Color Picker (%1)").arg(dialogTitle);
return background ? QStringLiteral("Color Picker (Background Color)") : QStringLiteral("Color Picker (Foreground Color)");
}
@@ -257,6 +259,8 @@ void EditorSession::closeColorPicker(bool commit)
setVignetteColor(commit ? color : picker.original);
} else if (picker.target.kind == ColorPickerTarget::Kind::dither) {
setDitherColor(commit ? color : picker.original, picker.target.light);
} else if (picker.target.kind == ColorPickerTarget::Kind::dialog) {
picker.dialogChange(commit ? color : picker.original);
} else if (picker.target.kind == ColorPickerTarget::Kind::effect) {
const PaletteColor chosen = commit ? color : picker.original;
changeEffects([&](LayerEffects &effects) { effects.setColor(chosen, picker.target.effect); });
@@ -440,3 +444,26 @@ std::optional<PaletteColor> EditorSession::sampleCompositeColor(QPointF point) c
return std::nullopt;
}
}
void EditorSession::openDialogColorPicker(const QString &title, const PaletteColor &color, std::function<void(const PaletteColor &)> change)
{
if (m_colorPicker)
return;
ColorPickerTarget target{ColorPickerTarget::Kind::dialog};
target.dialogTitle = title;
m_colorPicker.emplace(target, color);
m_colorPicker->dialogChange = std::move(change);
notify();
}
bool EditorSession::pickingForDialog() const
{
return m_colorPicker && m_colorPicker->target.kind == ColorPickerTarget::Kind::dialog;
}
// The dialog follows the working colour; the session keeps nothing.
void EditorSession::previewDialogColor() const
{
if (pickingForDialog())
m_colorPicker->dialogChange(m_colorPicker->color());
}
+6 -1
View File
@@ -3,6 +3,7 @@
#include <QColor>
#include <QString>
#include <QUuid>
#include <functional>
#include <optional>
// Swift's PaletteColor: an sRGB colour without alpha.
@@ -38,7 +39,7 @@ enum class LayerEffectKind;
// The picker's targets: palette, text, effect, a filter's colour.
struct ColorPickerTarget {
enum class Kind { palette, text, gradientMap, effect, vignette, dither };
enum class Kind { palette, text, gradientMap, effect, vignette, dither, dialog };
Kind kind;
bool background = false;
std::optional<QUuid> draftID = std::nullopt;
@@ -48,6 +49,8 @@ struct ColorPickerTarget {
LayerEffectKind effect{};
// Dither's Two Colors: the light one, else the dark.
bool light = false;
// A dialog's own colour, such as Export JPEG's background.
QString dialogTitle{};
QString title() const;
friend bool operator==(const ColorPickerTarget &, const ColorPickerTarget &) = default;
};
@@ -66,5 +69,7 @@ struct ColorPickerState {
LayerTextStyle style;
};
std::optional<EditedText> editedText;
// A dialog's colour: told as it moves, then on closing.
std::function<void(const PaletteColor &)> dialogChange;
PaletteColor color() const { return hsb.rgb().quantized(); }
};