diff --git a/libs/ui/CMakeLists.txt b/libs/ui/CMakeLists.txt --- a/libs/ui/CMakeLists.txt +++ b/libs/ui/CMakeLists.txt @@ -263,7 +263,8 @@ widgets/KoDualColorButton.cpp widgets/KoStrokeConfigWidget.cpp widgets/KoFillConfigWidget.cpp - + widgets/KisLayerStyleAngleSelector.cpp + KisPaletteEditor.cpp dialogs/KisDlgPaletteEditor.cpp @@ -528,6 +529,7 @@ layerstyles/WdgStroke.ui layerstyles/wdgstylesselector.ui layerstyles/wdgTexture.ui + layerstyles/wdgKisLayerStyleAngleSelector.ui wdgsplash.ui input/wintab/kis_screen_size_choice_dialog.ui diff --git a/libs/ui/dialogs/kis_dlg_layer_style.h b/libs/ui/dialogs/kis_dlg_layer_style.h --- a/libs/ui/dialogs/kis_dlg_layer_style.h +++ b/libs/ui/dialogs/kis_dlg_layer_style.h @@ -70,12 +70,6 @@ void setBevelAndEmboss(const psd_layer_effects_bevel_emboss *bevelAndEmboss); void fetchBevelAndEmboss(psd_layer_effects_bevel_emboss *bevelAndEmboss) const; -private Q_SLOTS: - void slotDialAngleChanged(int value); - void slotIntAngleChanged(int value); - - void slotGlobalLightToggled(); - Q_SIGNALS: void configChanged(); void globalAngleChanged(int value); @@ -127,12 +121,6 @@ void setShadow(const psd_layer_effects_shadow_common *shadow); void fetchShadow(psd_layer_effects_shadow_common *shadow) const; -private Q_SLOTS: - void slotDialAngleChanged(int value); - void slotIntAngleChanged(int value); - - void slotGlobalLightToggled(); - Q_SIGNALS: void configChanged(); void globalAngleChanged(int value); @@ -149,10 +137,6 @@ void setGradientOverlay(const psd_layer_effects_gradient_overlay *gradient); void fetchGradientOverlay(psd_layer_effects_gradient_overlay *gradient) const; -private Q_SLOTS: - void slotDialAngleChanged(int value); - void slotIntAngleChanged(int value); - Q_SIGNALS: void configChanged(); @@ -204,10 +188,6 @@ void setSatin(const psd_layer_effects_satin *satin); void fetchSatin(psd_layer_effects_satin *satin) const; -private Q_SLOTS: - void slotDialAngleChanged(int value); - void slotIntAngleChanged(int value); - Q_SIGNALS: void configChanged(); @@ -222,10 +202,6 @@ void setStroke(const psd_layer_effects_stroke *stroke); void fetchStroke(psd_layer_effects_stroke *stroke) const; -private Q_SLOTS: - void slotDialAngleChanged(int value); - void slotIntAngleChanged(int value); - Q_SIGNALS: void configChanged(); diff --git a/libs/ui/dialogs/kis_dlg_layer_style.cpp b/libs/ui/dialogs/kis_dlg_layer_style.cpp --- a/libs/ui/dialogs/kis_dlg_layer_style.cpp +++ b/libs/ui/dialogs/kis_dlg_layer_style.cpp @@ -29,7 +29,6 @@ #include #include - #include #include #include @@ -48,7 +47,6 @@ #include - KoAbstractGradient* fetchGradientLazy(KoAbstractGradient *gradient, KisCanvasResourceProvider *resourceProvider) { @@ -616,13 +614,10 @@ ui.intOpacity2->setRange(0, 100); ui.intOpacity2->setSuffix(i18n(" %")); - connect(ui.dialAngle, SIGNAL(valueChanged(int)), SLOT(slotDialAngleChanged(int))); - connect(ui.intAngle, SIGNAL(valueChanged(int)), SLOT(slotIntAngleChanged(int))); - connect(ui.chkUseGlobalLight, SIGNAL(toggled(bool)), SLOT(slotGlobalLightToggled())); + ui.angleSelector->enableGlobalLight(true); + connect(ui.angleSelector, SIGNAL(globalAngleChanged(int)), SIGNAL(globalAngleChanged(int))); + connect(ui.angleSelector, SIGNAL(configChanged()), SIGNAL(configChanged())); - connect(ui.dialAngle, SIGNAL(valueChanged(int)), SIGNAL(configChanged())); - connect(ui.intAngle, SIGNAL(valueChanged(int)), SIGNAL(configChanged())); - connect(ui.chkUseGlobalLight, SIGNAL(toggled(bool)), SIGNAL(configChanged())); connect(ui.intAltitude, SIGNAL(valueChanged(int)), SIGNAL(configChanged())); connect(ui.cmbContour, SIGNAL(currentIndexChanged(int)), SIGNAL(configChanged())); connect(ui.chkAntiAliased, SIGNAL(toggled(bool)), SIGNAL(configChanged())); @@ -664,9 +659,9 @@ ui.intSize->setValue(bevelAndEmboss->size()); ui.intSoften->setValue(bevelAndEmboss->soften()); - ui.dialAngle->setValue(bevelAndEmboss->angle()); - ui.intAngle->setValue(bevelAndEmboss->angle()); - ui.chkUseGlobalLight->setChecked(bevelAndEmboss->useGlobalLight()); + ui.angleSelector->setValue(bevelAndEmboss->angle()); + ui.angleSelector->setUseGlobalLight(bevelAndEmboss->useGlobalLight()); + ui.intAltitude->setValue(bevelAndEmboss->altitude()); // FIXME: curve editing // ui.cmbContour; @@ -702,8 +697,8 @@ bevelAndEmboss->setSize(ui.intSize->value()); bevelAndEmboss->setSoften(ui.intSoften->value()); - bevelAndEmboss->setAngle(ui.dialAngle->value()); - bevelAndEmboss->setUseGlobalLight(ui.chkUseGlobalLight->isChecked()); + bevelAndEmboss->setAngle(ui.angleSelector->value()); + bevelAndEmboss->setUseGlobalLight(ui.angleSelector->useGlobalLight()); bevelAndEmboss->setAltitude(ui.intAltitude->value()); bevelAndEmboss->setGlossAntiAliased(ui.chkAntiAliased->isChecked()); bevelAndEmboss->setHighlightBlendMode(ui.cmbHighlightMode->selectedCompositeOp().id()); @@ -724,32 +719,6 @@ bevelAndEmboss->setTextureAlignWithLayer(m_texture->ui.chkLinkWithLayer->isChecked()); } -void BevelAndEmboss::slotDialAngleChanged(int value) -{ - KisSignalsBlocker b(ui.intAngle); - ui.intAngle->setValue(value); - - if (ui.chkUseGlobalLight->isChecked()) { - emit globalAngleChanged(value); - } -} - -void BevelAndEmboss::slotIntAngleChanged(int value) -{ - KisSignalsBlocker b(ui.dialAngle); - ui.dialAngle->setValue(value); - - if (ui.chkUseGlobalLight->isChecked()) { - emit globalAngleChanged(value); - } -} - -void BevelAndEmboss::slotGlobalLightToggled() -{ - if (ui.chkUseGlobalLight->isChecked()) { - emit globalAngleChanged(ui.intAngle->value()); - } -} /********************************************************************/ /***** Texture *********************************************/ @@ -849,19 +818,15 @@ ui.intNoise->setRange(0, 100); ui.intNoise->setSuffix(i18n(" %")); - connect(ui.dialAngle, SIGNAL(valueChanged(int)), SLOT(slotDialAngleChanged(int))); - connect(ui.intAngle, SIGNAL(valueChanged(int)), SLOT(slotIntAngleChanged(int))); - connect(ui.chkUseGlobalLight, SIGNAL(toggled(bool)), SLOT(slotGlobalLightToggled())); + ui.angleSelector->enableGlobalLight(true); + connect(ui.angleSelector, SIGNAL(globalAngleChanged(int)), SIGNAL(globalAngleChanged(int))); + connect(ui.angleSelector, SIGNAL(configChanged()), SIGNAL(configChanged())); // connect everything to configChanged() signal connect(ui.cmbCompositeOp, SIGNAL(currentIndexChanged(int)), SIGNAL(configChanged())); connect(ui.intOpacity, SIGNAL(valueChanged(int)), SIGNAL(configChanged())); connect(ui.bnColor, SIGNAL(changed(KoColor)), SIGNAL(configChanged())); - connect(ui.dialAngle, SIGNAL(valueChanged(int)), SIGNAL(configChanged())); - connect(ui.intAngle, SIGNAL(valueChanged(int)), SIGNAL(configChanged())); - connect(ui.chkUseGlobalLight, SIGNAL(toggled(bool)), SIGNAL(configChanged())); - connect(ui.intDistance, SIGNAL(valueChanged(int)), SIGNAL(configChanged())); connect(ui.intSpread, SIGNAL(valueChanged(int)), SIGNAL(configChanged())); connect(ui.intSize, SIGNAL(valueChanged(int)), SIGNAL(configChanged())); @@ -879,44 +844,16 @@ } } -void DropShadow::slotDialAngleChanged(int value) -{ - KisSignalsBlocker b(ui.intAngle); - ui.intAngle->setValue(value); - - if (ui.chkUseGlobalLight->isChecked()) { - emit globalAngleChanged(value); - } -} - -void DropShadow::slotIntAngleChanged(int value) -{ - KisSignalsBlocker b(ui.dialAngle); - ui.dialAngle->setValue(value); - - if (ui.chkUseGlobalLight->isChecked()) { - emit globalAngleChanged(value); - } -} - -void DropShadow::slotGlobalLightToggled() -{ - if (ui.chkUseGlobalLight->isChecked()) { - emit globalAngleChanged(ui.intAngle->value()); - } -} - void DropShadow::setShadow(const psd_layer_effects_shadow_common *shadow) { ui.cmbCompositeOp->selectCompositeOp(KoID(shadow->blendMode())); ui.intOpacity->setValue(shadow->opacity()); KoColor color(KoColorSpaceRegistry::instance()->rgb8()); color.fromQColor(shadow->color()); ui.bnColor->setColor(color); - ui.dialAngle->setValue(shadow->angle()); - ui.intAngle->setValue(shadow->angle()); - ui.chkUseGlobalLight->setChecked(shadow->useGlobalLight()); + ui.angleSelector->setValue(shadow->angle()); + ui.angleSelector->setUseGlobalLight(shadow->useGlobalLight()); ui.intDistance->setValue(shadow->distance()); ui.intSpread->setValue(shadow->spread()); @@ -942,8 +879,8 @@ shadow->setOpacity(ui.intOpacity->value()); shadow->setColor(ui.bnColor->color().toQColor()); - shadow->setAngle(ui.dialAngle->value()); - shadow->setUseGlobalLight(ui.chkUseGlobalLight->isChecked()); + shadow->setAngle(ui.angleSelector->value()); + shadow->setUseGlobalLight(ui.angleSelector->useGlobalLight()); shadow->setDistance(ui.intDistance->value()); shadow->setSpread(ui.intSpread->value()); @@ -1015,17 +952,14 @@ ui.intScale->setRange(0, 100); ui.intScale->setSuffix(i18n(" %")); - connect(ui.dialAngle, SIGNAL(valueChanged(int)), SLOT(slotDialAngleChanged(int))); - connect(ui.intAngle, SIGNAL(valueChanged(int)), SLOT(slotIntAngleChanged(int))); + connect(ui.angleSelector, SIGNAL(configChanged()), SIGNAL(configChanged())); connect(ui.cmbCompositeOp, SIGNAL(currentIndexChanged(int)), SIGNAL(configChanged())); connect(ui.intOpacity, SIGNAL(valueChanged(int)), SIGNAL(configChanged())); connect(ui.cmbGradient, SIGNAL(gradientChanged(KoAbstractGradient*)), SIGNAL(configChanged())); connect(ui.chkReverse, SIGNAL(toggled(bool)), SIGNAL(configChanged())); connect(ui.cmbStyle, SIGNAL(currentIndexChanged(int)), SIGNAL(configChanged())); connect(ui.chkAlignWithLayer, SIGNAL(toggled(bool)), SIGNAL(configChanged())); - connect(ui.dialAngle, SIGNAL(valueChanged(int)), SIGNAL(configChanged())); - connect(ui.intAngle, SIGNAL(valueChanged(int)), SIGNAL(configChanged())); connect(ui.intScale, SIGNAL(valueChanged(int)), SIGNAL(configChanged())); } @@ -1044,8 +978,7 @@ ui.chkReverse->setChecked(config->reverse()); ui.cmbStyle->setCurrentIndex((int)config->style()); ui.chkAlignWithLayer->setCheckable(config->alignWithLayer()); - ui.dialAngle->setValue(config->angle()); - ui.intAngle->setValue(config->angle()); + ui.angleSelector->setValue(config->angle()); ui.intScale->setValue(config->scale()); } @@ -1057,21 +990,10 @@ config->setReverse(ui.chkReverse->isChecked()); config->setStyle((psd_gradient_style)ui.cmbStyle->currentIndex()); config->setAlignWithLayer(ui.chkAlignWithLayer->isChecked()); - config->setAngle(ui.dialAngle->value()); + config->setAngle(ui.angleSelector->value()); config->setScale(ui.intScale->value()); } -void GradientOverlay::slotDialAngleChanged(int value) -{ - KisSignalsBlocker b(ui.intAngle); - ui.intAngle->setValue(value); -} - -void GradientOverlay::slotIntAngleChanged(int value) -{ - KisSignalsBlocker b(ui.dialAngle); - ui.dialAngle->setValue(value); -} /********************************************************************/ /***** Innner Glow *********************************************/ @@ -1264,15 +1186,11 @@ ui.intSize->setRange(0, 250); ui.intSize->setSuffix(i18n(" px")); - connect(ui.dialAngle, SIGNAL(valueChanged(int)), SLOT(slotDialAngleChanged(int))); - connect(ui.intAngle, SIGNAL(valueChanged(int)), SLOT(slotIntAngleChanged(int))); - connect(ui.cmbCompositeOp, SIGNAL(currentIndexChanged(int)), SIGNAL(configChanged())); connect(ui.bnColor, SIGNAL(changed(KoColor)), SIGNAL(configChanged())); connect(ui.intOpacity, SIGNAL(valueChanged(int)), SIGNAL(configChanged())); - connect(ui.dialAngle, SIGNAL(valueChanged(int)), SIGNAL(configChanged())); - connect(ui.intAngle, SIGNAL(valueChanged(int)), SIGNAL(configChanged())); + connect(ui.angleSelector, SIGNAL(configChanged()), SIGNAL(configChanged())); connect(ui.intDistance, SIGNAL(valueChanged(int)), SIGNAL(configChanged())); connect(ui.intSize, SIGNAL(valueChanged(int)), SIGNAL(configChanged())); @@ -1282,28 +1200,15 @@ } -void Satin::slotDialAngleChanged(int value) -{ - KisSignalsBlocker b(ui.intAngle); - ui.intAngle->setValue(value); -} - -void Satin::slotIntAngleChanged(int value) -{ - KisSignalsBlocker b(ui.dialAngle); - ui.dialAngle->setValue(value); -} - void Satin::setSatin(const psd_layer_effects_satin *satin) { ui.cmbCompositeOp->selectCompositeOp(KoID(satin->blendMode())); KoColor color(KoColorSpaceRegistry::instance()->rgb8()); color.fromQColor(satin->color()); ui.bnColor->setColor(color); ui.intOpacity->setValue(satin->opacity()); - ui.dialAngle->setValue(satin->angle()); - ui.intAngle->setValue(satin->angle()); + ui.angleSelector->setValue(satin->angle()); ui.intDistance->setValue(satin->distance()); ui.intSize->setValue(satin->size()); @@ -1322,7 +1227,7 @@ satin->setOpacity(ui.intOpacity->value()); satin->setColor(ui.bnColor->color().toQColor()); - satin->setAngle(ui.dialAngle->value()); + satin->setAngle(ui.angleSelector->value()); satin->setDistance(ui.intDistance->value()); satin->setSize(ui.intSize->value()); @@ -1370,31 +1275,18 @@ connect(ui.chkReverse, SIGNAL(toggled(bool)), SIGNAL(configChanged())); connect(ui.cmbStyle, SIGNAL(currentIndexChanged(int)), SIGNAL(configChanged())); connect(ui.chkAlignWithLayer, SIGNAL(toggled(bool)), SIGNAL(configChanged())); - connect(ui.dialAngle, SIGNAL(valueChanged(int)), SLOT(slotDialAngleChanged(int))); - connect(ui.intAngle, SIGNAL(valueChanged(int)), SLOT(slotIntAngleChanged(int))); connect(ui.intScale, SIGNAL(valueChanged(int)), SIGNAL(configChanged())); + connect(ui.angleSelector, SIGNAL(configChanged()), SIGNAL(configChanged())); + connect(ui.patternChooser, SIGNAL(resourceSelected(KoResource*)), SIGNAL(configChanged())); connect(ui.chkLinkWithLayer, SIGNAL(toggled(bool)), SIGNAL(configChanged())); connect(ui.intScale_2, SIGNAL(valueChanged(int)), SIGNAL(configChanged())); // cold initialization ui.fillStack->setCurrentIndex(ui.cmbFillType->currentIndex()); } -void Stroke::slotDialAngleChanged(int value) -{ - KisSignalsBlocker b(ui.intAngle); - ui.intAngle->setValue(value); -} - -void Stroke::slotIntAngleChanged(int value) -{ - KisSignalsBlocker b(ui.dialAngle); - ui.dialAngle->setValue(value); -} - - void Stroke::setStroke(const psd_layer_effects_stroke *stroke) { @@ -1418,8 +1310,7 @@ ui.chkReverse->setChecked(stroke->antiAliased()); ui.cmbStyle->setCurrentIndex((int)stroke->style()); ui.chkAlignWithLayer->setCheckable(stroke->alignWithLayer()); - ui.dialAngle->setValue(stroke->angle()); - ui.intAngle->setValue(stroke->angle()); + ui.angleSelector->setValue(stroke->angle()); ui.intScale->setValue(stroke->scale()); ui.patternChooser->setCurrentPattern(stroke->pattern()); @@ -1443,7 +1334,7 @@ stroke->setReverse(ui.chkReverse->isChecked()); stroke->setStyle((psd_gradient_style)ui.cmbStyle->currentIndex()); stroke->setAlignWithLayer(ui.chkAlignWithLayer->isChecked()); - stroke->setAngle(ui.dialAngle->value()); + stroke->setAngle(ui.angleSelector->value()); stroke->setScale(ui.intScale->value()); stroke->setPattern(static_cast(ui.patternChooser->currentResource())); diff --git a/libs/ui/layerstyles/WdgGradientOverlay.ui b/libs/ui/layerstyles/WdgGradientOverlay.ui --- a/libs/ui/layerstyles/WdgGradientOverlay.ui +++ b/libs/ui/layerstyles/WdgGradientOverlay.ui @@ -6,8 +6,8 @@ 0 0 - 411 - 294 + 473 + 358 @@ -171,41 +171,11 @@ &Angle: - dialAngle + angleSelector - - - - - - Set the angle of the light source - - - -179 - - - 180 - - - true - - - - - - - -179 - - - 180 - - - - - - + S&cale: @@ -215,7 +185,7 @@ - + @@ -228,6 +198,33 @@ + + + + + + + 0 + 0 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + label_6 intScale @@ -259,11 +256,6 @@ - - KisIntParseSpinBox - QSpinBox -
kis_int_parse_spin_box.h
-
KisSliderSpinBox QWidget @@ -275,6 +267,12 @@ QComboBox
kis_cmb_composite.h
+ + KisLayerStyleAngleSelector + QWidget +
KisLayerStyleAngleSelector.h
+ 1 +
KisCmbGradient QToolButton diff --git a/libs/ui/layerstyles/WdgSatin.ui b/libs/ui/layerstyles/WdgSatin.ui --- a/libs/ui/layerstyles/WdgSatin.ui +++ b/libs/ui/layerstyles/WdgSatin.ui @@ -7,7 +7,7 @@ 0 0 400 - 345 + 429 @@ -89,49 +89,16 @@ - - - - + An&gle: - dialAngle + angleSelector - - - - - - Set the angle of the light source - - - -179 - - - 180 - - - true - - - - - - - -179 - - - 180 - - - - - @@ -199,6 +166,33 @@ + + + + + + + 0 + 0 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + cmbContour chkAntiAliased @@ -214,21 +208,8 @@ chkInvert - - - - Qt::Vertical - - - - 20 - 40 - - - - - + Qt::Vertical @@ -251,11 +232,6 @@ QPushButton
kis_color_button.h
- - KisIntParseSpinBox - QSpinBox -
kis_int_parse_spin_box.h
-
KisSliderSpinBox QWidget @@ -267,6 +243,12 @@ QComboBox
kis_cmb_composite.h
+ + KisLayerStyleAngleSelector + QWidget +
KisLayerStyleAngleSelector.h
+ 1 +
KisCmbContour QWidget diff --git a/libs/ui/layerstyles/WdgStroke.ui b/libs/ui/layerstyles/WdgStroke.ui --- a/libs/ui/layerstyles/WdgStroke.ui +++ b/libs/ui/layerstyles/WdgStroke.ui @@ -6,8 +6,8 @@ 0 0 - 406 - 642 + 457 + 781 @@ -149,7 +149,7 @@ - 0 + 1 @@ -264,41 +264,11 @@ &Angle: - dialAngle + angleSelector - - - - - - Set the angle of the light source - - - -179 - - - 180 - - - true - - - - - - - -179 - - - 180 - - - - - - + S&cale: @@ -308,7 +278,7 @@ - + @@ -321,6 +291,33 @@ + + + + + + + 0 + 0 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + @@ -399,19 +396,27 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + KisColorButton QPushButton
kis_color_button.h
- - KisIntParseSpinBox - QSpinBox -
kis_int_parse_spin_box.h
-
KisSliderSpinBox QWidget @@ -423,6 +428,12 @@ QComboBox
kis_cmb_composite.h
+ + KisLayerStyleAngleSelector + QWidget +
KisLayerStyleAngleSelector.h
+ 1 +
KisCmbGradient QToolButton diff --git a/libs/ui/layerstyles/wdgBevelAndEmboss.ui b/libs/ui/layerstyles/wdgBevelAndEmboss.ui --- a/libs/ui/layerstyles/wdgBevelAndEmboss.ui +++ b/libs/ui/layerstyles/wdgBevelAndEmboss.ui @@ -6,8 +6,8 @@ 0 0 - 399 - 541 + 453 + 669 @@ -128,6 +128,9 @@ Direction: + + cmbDirection + @@ -198,78 +201,44 @@ Shading - - - - - - - &Angle: - - - dialAngle - - - - - - - Set the angle of the light source - - - -179 - - - 180 - - - true - - - - - - - -179 - - - 180 - - - - - - - Qt::Vertical - - - - 20 - 18 - - - - - - - - Use &Global Light - - - - + + + + + &Angle: + + + angleSelector + + + + + + + + + + A&ltitude: + + + intAltitude + + - + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + -179 180 - + &Gloss Contour: @@ -279,7 +248,7 @@ - + @@ -293,7 +262,7 @@ - + H&ighlight Mode: @@ -303,7 +272,7 @@ - + @@ -321,20 +290,17 @@ - + &Opacity: - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - intOpacity - + @@ -356,7 +322,17 @@ - + + + + Sh&adow Mode: + + + cmbShadowMode + + + + @@ -374,20 +350,17 @@ - + &Opacity: - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - intOpacity2 - + @@ -409,29 +382,6 @@ - - - - Altitude: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - dialAngle - - - - - - - Sh&adow Mode: - - - cmbShadowMode - - - @@ -454,16 +404,16 @@ - - KisColorButton - QPushButton -
kis_color_button.h
-
KisIntParseSpinBox QSpinBox
kis_int_parse_spin_box.h
+ + KisColorButton + QPushButton +
kis_color_button.h
+
KisSliderSpinBox QWidget @@ -475,6 +425,12 @@ QComboBox
kis_cmb_composite.h
+ + KisLayerStyleAngleSelector + QWidget +
KisLayerStyleAngleSelector.h
+ 1 +
diff --git a/libs/ui/layerstyles/wdgKisLayerStyleAngleSelector.ui b/libs/ui/layerstyles/wdgKisLayerStyleAngleSelector.ui new file mode 100644 --- /dev/null +++ b/libs/ui/layerstyles/wdgKisLayerStyleAngleSelector.ui @@ -0,0 +1,95 @@ + + + WdgKisLayerStyleAngleSelector + + + + 0 + 0 + 273 + 76 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + Set the angle of the light source + + + 0 + + + 360 + + + 0 + + + true + + + true + + + + + + + + + true + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + ˚ + + + -179 + + + 180 + + + + + + + Use global light + + + + + + + + + + KisIntParseSpinBox + QSpinBox +
kis_int_parse_spin_box.h
+
+
+ + +
diff --git a/libs/ui/layerstyles/wdgdropshadow.ui b/libs/ui/layerstyles/wdgdropshadow.ui --- a/libs/ui/layerstyles/wdgdropshadow.ui +++ b/libs/ui/layerstyles/wdgdropshadow.ui @@ -6,8 +6,8 @@ 0 0 - 435 - 390 + 491 + 495 @@ -17,6 +17,19 @@ Drop Shadow + + + + Qt::Vertical + + + + 20 + 40 + + + + @@ -96,16 +109,6 @@ Structure - - - - &Blend Mode: - - - cmbCompositeOp - - - @@ -119,19 +122,19 @@ - - - - - - - Opaci&ty: - - - intOpacity + + + + + 0 + 0 + + + + @@ -154,57 +157,7 @@ - - - - An&gle: - - - dialAngle - - - - - - - - - Set the angle of the light source - - - -179 - - - 180 - - - true - - - - - - - -179 - - - 180 - - - - - - - Use current setting for global light source - - - Use &Global light - - - - - - + &Distance: @@ -214,17 +167,37 @@ - - + + 0 0 - + + + + Opaci&ty: + + + intOpacity + + + + + + + An&gle: + + + angleSelector + + + + Sp&read: @@ -234,7 +207,7 @@ - + @@ -244,7 +217,7 @@ - + S&ize: @@ -254,32 +227,22 @@ - - - - - 0 - 0 - + + + + &Blend Mode: + + + cmbCompositeOp + + + - - - - Qt::Vertical - - - - 20 - 40 - - - -
@@ -291,11 +254,6 @@ QPushButton
kis_color_button.h
- - KisIntParseSpinBox - QSpinBox -
kis_int_parse_spin_box.h
-
KisSliderSpinBox QWidget @@ -307,6 +265,12 @@ QComboBox
kis_cmb_composite.h
+ + KisLayerStyleAngleSelector + QWidget +
KisLayerStyleAngleSelector.h
+ 1 +
KisCmbContour QWidget diff --git a/libs/ui/widgets/KisLayerStyleAngleSelector.h b/libs/ui/widgets/KisLayerStyleAngleSelector.h new file mode 100644 --- /dev/null +++ b/libs/ui/widgets/KisLayerStyleAngleSelector.h @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2018 Anna Medonosova + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef KISLAYERSTYLEANGLESELECTOR_H +#define KISLAYERSTYLEANGLESELECTOR_H + +#include +#include +#include + +#include + +class KisLayerStyleAngleSelector : public QWidget +{ + Q_OBJECT + +public: + KisLayerStyleAngleSelector(QWidget* parent); + + int value(); + void setValue(int value); + + void enableGlobalLight(bool enable); + + bool useGlobalLight(); + void setUseGlobalLight(bool state); + +Q_SIGNALS: + void valueChanged(int); + void configChanged(); + void globalAngleChanged(int); + +private Q_SLOTS: + void slotDialAngleChanged(int value); + void slotIntAngleChanged(int value); + void slotGlobalLightToggled(); + +private: + void emitChangeSignals(); + + Ui_WdgKisLayerStyleAngleSelector* ui; + + // BUG: 372169 + // Adobe's dial widget differs from QDial by 90 degrees, + // therefore we need to apply this magic constant + // to this widget's QDial for consistency between + // the settings dialogs and on-canvas effects. + // Wrapping is handled by QDial itself. + const static int m_dialValueShift = 90; + + bool m_enableGlobalLight; +}; + +#endif // KISLAYERSTYLEANGLESELECTOR_H diff --git a/libs/ui/widgets/KisLayerStyleAngleSelector.cpp b/libs/ui/widgets/KisLayerStyleAngleSelector.cpp new file mode 100644 --- /dev/null +++ b/libs/ui/widgets/KisLayerStyleAngleSelector.cpp @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2018 Anna Medonosova + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "KisLayerStyleAngleSelector.h" + +#include +#include + +#include + +KisLayerStyleAngleSelector::KisLayerStyleAngleSelector(QWidget *parent) + : QWidget(parent) + , m_enableGlobalLight(false) +{ + ui = new Ui_WdgKisLayerStyleAngleSelector(); + ui->setupUi(this); + + ui->chkUseGlobalLight->hide(); + + connect(ui->dialAngle, SIGNAL(valueChanged(int)), SLOT(slotDialAngleChanged(int))); + connect(ui->intAngle, SIGNAL(valueChanged(int)), SLOT(slotIntAngleChanged(int))); +} + +int KisLayerStyleAngleSelector::value() +{ + return ui->intAngle->value(); +} + +void KisLayerStyleAngleSelector::setValue(int value) +{ + KisSignalsBlocker intB(ui->intAngle); + KisSignalsBlocker dialB(ui->dialAngle); + + ui->intAngle->setValue(value); + ui->dialAngle->setValue(value + m_dialValueShift); +} + +void KisLayerStyleAngleSelector::enableGlobalLight(bool enable) +{ + m_enableGlobalLight = enable; + + if (enable) { + ui->chkUseGlobalLight->show(); + connect(ui->chkUseGlobalLight, SIGNAL(toggled(bool)), SLOT(slotGlobalLightToggled())); + } else { + ui->chkUseGlobalLight->hide(); + disconnect(ui->chkUseGlobalLight, SIGNAL(toggled(bool)), this, SLOT(slotGlobalLightToggled())); + } +} + +bool KisLayerStyleAngleSelector::useGlobalLight() +{ + return m_enableGlobalLight && ui->chkUseGlobalLight->isChecked(); +} + +void KisLayerStyleAngleSelector::setUseGlobalLight(bool state) +{ + ui->chkUseGlobalLight->setChecked(state); +} + +void KisLayerStyleAngleSelector::slotDialAngleChanged(int value) +{ + KisSignalsBlocker b(ui->intAngle); + + int normalizedValue = 0; + if (value >= 270 && value <= 360) { + // Due to the mismatch between the domain of the dial (0°,360°) + // and the spinbox (-179°,180°), the shift in the third quadrant + // of the dial is different + normalizedValue = value - 360 - m_dialValueShift; + } else { + normalizedValue = value - m_dialValueShift; + } + + ui->intAngle->setValue(normalizedValue); + emit valueChanged(normalizedValue); + emitChangeSignals(); +} + +void KisLayerStyleAngleSelector::slotIntAngleChanged(int value) +{ + KisSignalsBlocker b(ui->dialAngle); + + int angleDialValue = value + m_dialValueShift; + ui->dialAngle->setValue(angleDialValue); + + emit valueChanged(value); + emitChangeSignals(); +} + +void KisLayerStyleAngleSelector::slotGlobalLightToggled() +{ + emitChangeSignals(); +} + +void KisLayerStyleAngleSelector::emitChangeSignals() +{ + if (useGlobalLight()) { + emit globalAngleChanged(value()); + } + + emit configChanged(); +}