File indexing completed on 2025-02-02 04:11:32

0001 /*
0002  * SPDX-FileCopyrightText: 2019-2023 Mattia Basaglia <dev@dragon.best>
0003  *
0004  * SPDX-License-Identifier: GPL-3.0-or-later
0005  */
0006 
0007 #ifndef STROKESTYLEWIDGET_H
0008 #define STROKESTYLEWIDGET_H
0009 
0010 #include <memory>
0011 #include <QWidget>
0012 
0013 #include "model/shapes/stroke.hpp"
0014 
0015 
0016 namespace color_widgets {
0017 class ColorPaletteModel;
0018 } // namespace color_widgets
0019 
0020 namespace glaxnimate::gui {
0021 
0022 class StrokeStyleWidget : public QWidget
0023 {
0024     Q_OBJECT
0025 
0026 public:
0027     StrokeStyleWidget(QWidget* parent = nullptr);
0028 
0029     ~StrokeStyleWidget();
0030 
0031     void save_settings() const;
0032 
0033     model::Stroke* current() const;
0034     void set_current(model::Stroke* stroke);
0035     void set_targets(std::vector<model::Stroke*> targets);
0036 
0037     void set_stroke_width(qreal w);
0038 
0039     void set_gradient_stop(model::Styler* styler, int index);
0040 
0041     QPen pen_style() const;
0042     QColor current_color() const;
0043 
0044     void set_palette_model(color_widgets::ColorPaletteModel* palette_model);
0045 
0046 private:
0047     void before_set_target();
0048     void after_set_target();
0049 
0050 protected:
0051     void changeEvent ( QEvent* e ) override;
0052     void paintEvent(QPaintEvent * event) override;
0053 
0054 public Q_SLOTS:
0055     void set_color(const QColor& color);
0056 
0057 Q_SIGNALS:
0058     void color_changed(const QColor& color);
0059     void pen_style_changed();
0060 
0061 private Q_SLOTS:
0062     void check_cap();
0063     void check_join();
0064     void check_color(const QColor& color);
0065     void color_committed(const QColor& color);
0066     void property_changed(const model::BaseProperty* prop);
0067     void check_width(double w);
0068     void check_miter(double w);
0069     void commit_width();
0070     void clear_color();
0071 
0072 private:
0073     class Private;
0074     std::unique_ptr<Private> d;
0075 };
0076 
0077 } // namespace glaxnimate::gui
0078 #endif // STROKESTYLEWIDGET_H