File indexing completed on 2025-02-02 04:18:28
0001 /* 0002 * SPDX-FileCopyrightText: 2014 Boudewijn Rempt <boud@valdyas.org> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 #ifndef KIS_DLG_LAYER_STYLE_H 0007 #define KIS_DLG_LAYER_STYLE_H 0008 0009 #include <QUuid> 0010 0011 #include <KoDialog.h> 0012 0013 #include "kis_types.h" 0014 0015 #include "ui_wdglayerstyles.h" 0016 #include "ui_wdgBevelAndEmboss.h" 0017 #include "ui_wdgblendingoptions.h" 0018 #include "ui_WdgColorOverlay.h" 0019 #include "ui_wdgContour.h" 0020 #include "ui_wdgdropshadow.h" 0021 #include "ui_WdgGradientOverlay.h" 0022 #include "ui_wdgInnerGlow.h" 0023 #include "ui_WdgPatternOverlay.h" 0024 #include "ui_WdgSatin.h" 0025 #include "ui_WdgStroke.h" 0026 #include "ui_wdgstylesselector.h" 0027 #include "ui_wdgTexture.h" 0028 0029 0030 #include <QSortFilterProxyModel> 0031 0032 #include <kis_psd_layer_style.h> 0033 0034 class QListWidgetItem; 0035 class KisSignalCompressor; 0036 class KisCanvasResourceProvider; 0037 0038 0039 class Contour : public QWidget { 0040 Q_OBJECT 0041 public: 0042 Contour(QWidget *parent); 0043 Ui::WdgContour ui; 0044 }; 0045 0046 0047 class Texture : public QWidget { 0048 Q_OBJECT 0049 public: 0050 Texture(QWidget *parent); 0051 Ui::WdgTexture ui; 0052 }; 0053 0054 0055 class BevelAndEmboss : public QWidget { 0056 Q_OBJECT 0057 public: 0058 BevelAndEmboss(Contour *contour, Texture *texture, QWidget *parent); 0059 void setBevelAndEmboss(const psd_layer_effects_bevel_emboss *bevelAndEmboss); 0060 void fetchBevelAndEmboss(psd_layer_effects_bevel_emboss *bevelAndEmboss) const; 0061 0062 Q_SIGNALS: 0063 void configChanged(); 0064 void globalAngleChanged(int value); 0065 0066 private: 0067 Contour *m_contour; 0068 Texture *m_texture; 0069 Ui::WdgBevelAndEmboss ui; 0070 }; 0071 0072 class BlendingOptions : public QWidget { 0073 Q_OBJECT 0074 public: 0075 BlendingOptions(QWidget *parent); 0076 Q_SIGNALS: 0077 void configChanged(); 0078 0079 private: 0080 Ui::WdgBlendingOptions ui; 0081 }; 0082 0083 0084 class ColorOverlay : public QWidget { 0085 Q_OBJECT 0086 public: 0087 ColorOverlay(QWidget *parent); 0088 void setColorOverlay(const psd_layer_effects_color_overlay *colorOverlay); 0089 void fetchColorOverlay(psd_layer_effects_color_overlay *colorOverlay) const; 0090 0091 Q_SIGNALS: 0092 void configChanged(); 0093 0094 private: 0095 Ui::WdgColorOverlay ui; 0096 }; 0097 0098 0099 class DropShadow : public QWidget { 0100 Q_OBJECT 0101 0102 public: 0103 enum Mode { 0104 DropShadowMode, 0105 InnerShadowMode 0106 }; 0107 0108 public: 0109 DropShadow(Mode mode, QWidget *parent); 0110 void setShadow(const psd_layer_effects_shadow_common *shadow); 0111 void fetchShadow(psd_layer_effects_shadow_common *shadow) const; 0112 0113 Q_SIGNALS: 0114 void configChanged(); 0115 void globalAngleChanged(int value); 0116 0117 private: 0118 Ui::WdgDropShadow ui; 0119 Mode m_mode; 0120 }; 0121 0122 class GradientOverlay : public QWidget { 0123 Q_OBJECT 0124 public: 0125 GradientOverlay(KisCanvasResourceProvider *resourceProvider, QWidget *parent); 0126 void setGradientOverlay(const psd_layer_effects_gradient_overlay *gradient); 0127 void fetchGradientOverlay(psd_layer_effects_gradient_overlay *gradient) const; 0128 0129 Q_SIGNALS: 0130 void configChanged(); 0131 0132 private: 0133 Ui::WdgGradientOverlay ui; 0134 KisCanvasResourceProvider *m_resourceProvider; 0135 }; 0136 0137 class InnerGlow : public QWidget { 0138 Q_OBJECT 0139 public: 0140 enum Mode { 0141 InnerGlowMode = 0, 0142 OuterGlowMode 0143 }; 0144 0145 public: 0146 InnerGlow(Mode mode, KisCanvasResourceProvider *resourceProvider, QWidget *parent); 0147 void setConfig(const psd_layer_effects_glow_common *innerGlow); 0148 void fetchConfig(psd_layer_effects_glow_common *innerGlow) const; 0149 0150 Q_SIGNALS: 0151 void configChanged(); 0152 0153 private: 0154 Ui::WdgInnerGlow ui; 0155 Mode m_mode; 0156 KisCanvasResourceProvider *m_resourceProvider; 0157 }; 0158 0159 class PatternOverlay : public QWidget { 0160 Q_OBJECT 0161 public: 0162 PatternOverlay(QWidget *parent); 0163 void setPatternOverlay(const psd_layer_effects_pattern_overlay *pattern); 0164 void fetchPatternOverlay(psd_layer_effects_pattern_overlay *pattern) const; 0165 0166 Q_SIGNALS: 0167 void configChanged(); 0168 0169 private: 0170 Ui::WdgPatternOverlay ui; 0171 }; 0172 0173 class Satin : public QWidget { 0174 Q_OBJECT 0175 public: 0176 Satin(QWidget *parent); 0177 void setSatin(const psd_layer_effects_satin *satin); 0178 void fetchSatin(psd_layer_effects_satin *satin) const; 0179 0180 Q_SIGNALS: 0181 void configChanged(); 0182 0183 private: 0184 Ui::WdgSatin ui; 0185 }; 0186 0187 class Stroke : public QWidget { 0188 Q_OBJECT 0189 public: 0190 Stroke(KisCanvasResourceProvider *resourceProvider, QWidget *parent); 0191 void setStroke(const psd_layer_effects_stroke *stroke); 0192 void fetchStroke(psd_layer_effects_stroke *stroke) const; 0193 0194 Q_SIGNALS: 0195 void configChanged(); 0196 0197 private: 0198 Ui::WdgStroke ui; 0199 KisCanvasResourceProvider *m_resourceProvider; 0200 }; 0201 0202 0203 class KisResourceModel; 0204 class StylesSelector : public QWidget { 0205 Q_OBJECT 0206 0207 protected: 0208 class LocationProxyModel : public QSortFilterProxyModel 0209 { 0210 public: 0211 LocationProxyModel(QObject* parent); 0212 0213 void setEnableFiltering(bool enableFiltering); 0214 void setLocationToFilterBy(QString location); 0215 0216 private: 0217 QString m_locationToFilter; 0218 bool m_enableFiltering {false}; 0219 0220 0221 // QSortFilterProxyModel interface 0222 protected: 0223 bool filterAcceptsRow(int source_row, 0224 const QModelIndex &source_parent) const override; 0225 }; 0226 0227 0228 public: 0229 StylesSelector(QWidget *parent); 0230 0231 void notifyExternalStyleChanged(const QString &name, const QUuid &uuid); 0232 0233 void addNewStyle(const QString &location, const KisPSDLayerStyleSP style); 0234 void loadCollection(const QString &fileName); 0235 0236 void refillCollections(); 0237 0238 private Q_SLOTS: 0239 0240 void slotResourceModelReset(); 0241 0242 void loadStyles(const QString &name); 0243 void selectStyle(QModelIndex current); 0244 Q_SIGNALS: 0245 void styleSelected(KisPSDLayerStyleSP style); 0246 0247 0248 0249 0250 private: 0251 Ui::WdgStylesSelector ui; 0252 LocationProxyModel* m_locationsProxyModel; 0253 KisResourceModel* m_resourceModel; 0254 }; 0255 0256 class KisDlgLayerStyle : public KoDialog 0257 { 0258 Q_OBJECT 0259 public: 0260 explicit KisDlgLayerStyle(KisPSDLayerStyleSP layerStyle, KisCanvasResourceProvider *resourceProvider, QWidget *parent = 0); 0261 ~KisDlgLayerStyle() override; 0262 0263 KisPSDLayerStyleSP style() const; 0264 0265 Q_SIGNALS: 0266 void configChanged(); 0267 0268 public Q_SLOTS: 0269 void slotMasterFxSwitchChanged(bool value); 0270 void syncGlobalAngle(int angle); 0271 0272 void notifyGuiConfigChanged(); 0273 void notifyPredefinedStyleSelected(KisPSDLayerStyleSP style); 0274 0275 void slotBevelAndEmbossChanged(QListWidgetItem*); 0276 0277 void changePage(QListWidgetItem *, QListWidgetItem*); 0278 0279 void slotNotifyOnAccept(); 0280 void slotNotifyOnReject(); 0281 0282 // Sets all the widgets to the contents of the given style 0283 void setStyle(KisPSDLayerStyleSP style); 0284 0285 void slotLoadStyle(); 0286 void slotSaveStyle(); 0287 void slotNewStyle(); 0288 0289 private: 0290 0291 KisPSDLayerStyleSP m_layerStyle; 0292 KisPSDLayerStyleSP m_initialLayerStyle; 0293 0294 Ui::WdgStylesDialog wdgLayerStyles; 0295 0296 BevelAndEmboss *m_bevelAndEmboss; 0297 BlendingOptions *m_blendingOptions; 0298 ColorOverlay *m_colorOverlay; 0299 Contour *m_contour; 0300 DropShadow *m_dropShadow; 0301 GradientOverlay *m_gradientOverlay; 0302 InnerGlow *m_innerGlow; 0303 DropShadow *m_innerShadow; 0304 InnerGlow *m_outerGlow; 0305 PatternOverlay * m_patternOverlay; 0306 Satin *m_satin; 0307 Stroke *m_stroke; 0308 StylesSelector *m_stylesSelector; 0309 Texture *m_texture; 0310 0311 KisSignalCompressor *m_configChangedCompressor; 0312 bool m_isSwitchingPredefinedStyle; 0313 0314 /** 0315 * Used for debugging purposes only to track if m_layerStyle is in 0316 * sync with what is stored in the GUI 0317 */ 0318 mutable bool m_sanityLayerStyleDirty; 0319 }; 0320 0321 #endif // KIS_DLG_LAYER_STYLE_H