127 lines
5.2 KiB
C++
127 lines
5.2 KiB
C++
#pragma once
|
|
#include "Document/EditorSession.h"
|
|
#include "UI/CameraRawSlider.h"
|
|
#include <QWidget>
|
|
|
|
class CurvesControls;
|
|
class PickerField;
|
|
class QButtonGroup;
|
|
class QCheckBox;
|
|
class QComboBox;
|
|
class QLabel;
|
|
class QProgressBar;
|
|
class QPushButton;
|
|
class QSlider;
|
|
class QVBoxLayout;
|
|
class SwatchButton;
|
|
|
|
// Swift's GradientMapControls: the gradient, both ends, Reverse.
|
|
class GradientMapControls : public QWidget {
|
|
Q_OBJECT
|
|
public:
|
|
// `pick` opens the picker: false for Shadows, true for Highlights.
|
|
GradientMapControls(std::function<GradientMapSettings()> value, std::function<void(const GradientMapSettings &)> change,
|
|
std::function<void(bool)> pick, QWidget *parent = nullptr);
|
|
// Shows the settings as they now stand.
|
|
void synchronize();
|
|
|
|
private:
|
|
QWidget *swatch(const QString &title, bool highlights, const std::function<void(bool)> &pick);
|
|
|
|
const std::function<GradientMapSettings()> m_value;
|
|
const std::function<void(const GradientMapSettings &)> m_change;
|
|
QWidget *const m_gradient;
|
|
QCheckBox *const m_reverse;
|
|
std::vector<SwatchButton *> m_swatches;
|
|
};
|
|
|
|
// Swift's FilterSheet: the kind's settings, Preview, Cancel and OK.
|
|
class FilterSheet : public QWidget {
|
|
Q_OBJECT
|
|
public:
|
|
explicit FilterSheet(EditorSession &session, QWidget *parent = nullptr);
|
|
~FilterSheet() override;
|
|
// Swift's resetting: that setting back to the filter's default.
|
|
static FilterSettings resetting(const std::function<double &(FilterSettings &)> &key, FilterSettings settings);
|
|
// Color Balance's tracks, each colour to its opposite.
|
|
static CameraRawSliderTrack cyanRedTrack();
|
|
static CameraRawSliderTrack magentaGreenTrack();
|
|
static CameraRawSliderTrack yellowBlueTrack();
|
|
|
|
protected:
|
|
bool eventFilter(QObject *watched, QEvent *event) override;
|
|
|
|
private:
|
|
// Swift's control: a slider, an exact field and its unit.
|
|
struct Control {
|
|
std::function<double &(FilterSettings &)> key;
|
|
double low;
|
|
double high;
|
|
int decimals;
|
|
bool logarithmic;
|
|
QSlider *slider;
|
|
PickerField *field;
|
|
QLabel *title;
|
|
// A coloured track, as Camera Raw's; a double click resets.
|
|
std::function<CameraRawSliderTrack(const FilterSettings &)> track;
|
|
};
|
|
// A slider's travel: thousandths of its range.
|
|
static constexpr int travel = 1000;
|
|
void control(const QString &title, std::function<double &(FilterSettings &)> key, double low, double high, const QString &unit,
|
|
int decimals, bool logarithmic, std::function<CameraRawSliderTrack(const FilterSettings &)> track = {});
|
|
void showControl(Control &control, const FilterSettings &settings);
|
|
// Swift's LabelWidthKey: every shown title as wide as the widest.
|
|
void alignTitles();
|
|
void reset(size_t index);
|
|
void noise();
|
|
// Vignette's colour and rows, Bloom / Glow's, Tonal Contrast's.
|
|
void finishing(FilterKind kind);
|
|
// Swift's ditherControls: style, sizes, tones, colours, shape.
|
|
void dither();
|
|
// Swift's scanlinesControls: lines, displacement, tone, colours.
|
|
void scanlines();
|
|
// The Colors menu, then Two Colors' dark and light swatches.
|
|
void colorChoices(const QString &prefix, std::function<DitherColors &(FilterSettings &)> colors,
|
|
std::function<std::pair<AdjustmentColor, AdjustmentColor>(const FilterSettings &)> pair, const QString &darkHelp,
|
|
const QString &lightHelp);
|
|
// A titled menu of choices: the row and its box.
|
|
QComboBox *menu(const QString &title, const QString &name, const QString &help);
|
|
// Remove Background's words, Quality, and Advanced's three rows.
|
|
void background();
|
|
// Black & White's six families and Tint; Color Balance's nine.
|
|
void blackWhite();
|
|
void colorBalance();
|
|
// Swift's Toggle over a flag, with its help.
|
|
void flag(const QString &title, const QString &help, std::function<bool &(FilterSettings &)> key);
|
|
// Swift's headline over a group of rows.
|
|
void headline(const QString &title);
|
|
// Swift's `settings` and `update`: the defaults once the edit goes.
|
|
FilterSettings settings() const;
|
|
void update(const std::function<void(FilterSettings &)> &change);
|
|
void synchronize();
|
|
|
|
EditorSession &m_session;
|
|
QVBoxLayout *const m_column;
|
|
std::vector<Control> m_controls;
|
|
CurvesControls *m_curves = nullptr;
|
|
GradientMapControls *m_gradientMap = nullptr;
|
|
SwatchButton *m_vignetteSwatch = nullptr;
|
|
QButtonGroup *m_distribution = nullptr;
|
|
QCheckBox *m_monochromatic = nullptr;
|
|
QButtonGroup *m_quality = nullptr;
|
|
std::vector<std::pair<QCheckBox *, std::function<bool &(FilterSettings &)>>> m_flags;
|
|
// Rows under Swift's `if`: Advanced's, Tint's.
|
|
std::vector<std::pair<QWidget *, std::function<bool(const FilterSettings &)>>> m_shownWhen;
|
|
// Controls that show the settings as they stand: Dither's menus.
|
|
std::vector<std::function<void(const FilterSettings &)>> m_follows;
|
|
QCheckBox *const m_preview;
|
|
QLabel *const m_error;
|
|
QLabel *const m_limited;
|
|
QProgressBar *const m_spinner;
|
|
QLabel *const m_activity;
|
|
QPushButton *const m_cancel;
|
|
QPushButton *const m_ok;
|
|
// The picker's colour as last seen, Swift's onChange.
|
|
std::optional<PaletteColor> m_pickerColour;
|
|
};
|