#pragma once #include "Document/EditorSession.h" #include "UI/CameraRawSlider.h" #include 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 value, std::function change, std::function pick, QWidget *parent = nullptr); // Shows the settings as they now stand. void synchronize(); private: QWidget *swatch(const QString &title, bool highlights, const std::function &pick); const std::function m_value; const std::function m_change; QWidget *const m_gradient; QCheckBox *const m_reverse; std::vector 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 &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 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 track; }; // A slider's travel: thousandths of its range. static constexpr int travel = 1000; void control(const QString &title, std::function key, double low, double high, const QString &unit, int decimals, bool logarithmic, std::function 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 colors, std::function(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 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 &change); void synchronize(); EditorSession &m_session; QVBoxLayout *const m_column; std::vector 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>> m_flags; // Rows under Swift's `if`: Advanced's, Tint's. std::vector>> m_shownWhen; // Controls that show the settings as they stand: Dither's menus. std::vector> 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 m_pickerColour; };