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

0001 /*
0002  * SPDX-FileCopyrightText: 2019-2023 Mattia Basaglia <dev@dragon.best>
0003  *
0004  * SPDX-License-Identifier: GPL-3.0-or-later
0005  */
0006 
0007 #pragma once
0008 #include "color_selector.hpp"
0009 #include "model/shapes/fill.hpp"
0010 #include "utils/pseudo_mutex.hpp"
0011 
0012 namespace glaxnimate::gui {
0013 
0014 class FillStyleWidget : public ColorSelector
0015 {
0016 public:
0017     FillStyleWidget(QWidget* parent = nullptr);
0018 
0019     void set_targets(const std::vector<model::Fill*>& targets);
0020     model::Fill* current() const;
0021     void set_current(model::Fill* current);
0022 
0023     void set_gradient_stop(model::Styler* styler, int index);
0024 
0025 private:
0026     void update_from_target();
0027 
0028     void set_color(const QColor& color, bool commit);
0029 
0030     void before_set_target();
0031     void after_set_target();
0032 
0033 private Q_SLOTS:
0034     void set_target_color(const QColor& color);
0035 
0036     void commit_target_color();
0037 
0038     void property_changed(const model::BaseProperty* prop);
0039 
0040     void clear_target_color();
0041 
0042 private:
0043     std::vector<model::Styler*> targets;
0044     model::Styler* current_target = nullptr;
0045     utils::PseudoMutex updating;
0046     int stop = -1;
0047 };
0048 
0049 } // namespace glaxnimate::gui