[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/krita/plugins/paintops/spray
From: Lukáš Tvrdý <lukast.dev () gmail ! com>
Date: 2009-12-03 22:20:47
Message-ID: 1259878847.788116.18071.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1058075 by lukast:
Keep aspect ratio for particles.
TODO: merge proportional option somehow
M +75 -12 kis_spray_shape_option.cpp
M +10 -0 kis_spray_shape_option.h
M +101 -58 wdgshapeoptions.ui
--- trunk/koffice/krita/plugins/paintops/spray/kis_spray_shape_option.cpp #1058074:1058075
@@ -18,6 +18,8 @@
#include "kis_spray_shape_option.h"
#include <klocale.h>
+#include <KoImageResource.h>
+
#include <QImage>
#include "ui_wdgshapeoptions.h"
@@ -28,6 +30,8 @@
KisShapeOptionsWidget(QWidget *parent = 0)
: QWidget(parent) {
setupUi(this);
+ KoImageResource kir;
+ btnAspect->setIcon(QIcon(kir.chain()));
}
};
@@ -37,6 +41,24 @@
{
m_checkable = false;
m_options = new KisShapeOptionsWidget();
+ m_useAspect = m_options->btnAspect->isChecked();
+ computeAspect();
+
+ // UI signals
+ connect(m_options->btnAspect, SIGNAL(toggled(bool)), this, SLOT(aspectToggled(bool)));
+ connect(m_options->randomSlider,SIGNAL(valueChanged(int)),this,SLOT(randomValueChanged(int)));
+ connect(m_options->followSlider,SIGNAL(valueChanged(int)),this,SLOT(followValueChanged(int)));
+ connect(m_options->imageUrl,SIGNAL(textChanged(QString)),this,SLOT(prepareImage()));
+
+ connect(m_options->widthSpin, SIGNAL(valueChanged(int)), SLOT(updateHeight(int)));
+ connect(m_options->heightSpin, SIGNAL(valueChanged(int)), SLOT(updateWidth(int)));
+
+ setConfigurationPage(m_options);
+}
+
+
+void KisSprayShapeOption::setupBrushPreviewSignals()
+{
connect(m_options->shapeBox, SIGNAL(currentIndexChanged(int)), SIGNAL(sigSettingChanged()));
connect(m_options->widthSpin, SIGNAL(valueChanged(int)), SIGNAL(sigSettingChanged()));
connect(m_options->heightSpin, SIGNAL(valueChanged(int)), SIGNAL(sigSettingChanged()));
@@ -45,15 +67,9 @@
connect(m_options->widthPro, SIGNAL(valueChanged(double)), SIGNAL(sigSettingChanged()));
connect(m_options->proportionalBox, SIGNAL(toggled(bool)), SIGNAL(sigSettingChanged()));
connect(m_options->gaussBox, SIGNAL(toggled(bool)), SIGNAL(sigSettingChanged()));
+}
- connect(m_options->randomSlider,SIGNAL(valueChanged(int)),this,SLOT(randomValueChanged(int)));
- connect(m_options->followSlider,SIGNAL(valueChanged(int)),this,SLOT(followValueChanged(int)));
- connect(m_options->imageUrl,SIGNAL(textChanged(QString)),this,SLOT(prepareImage()));
-
- setConfigurationPage(m_options);
-}
-
KisSprayShapeOption::~KisSprayShapeOption()
{
// delete m_options;
@@ -99,15 +115,13 @@
// TODO
void KisSprayShapeOption::writeOptionSetting(KisPropertiesConfiguration* setting) const
{
-// setting->setProperty( "Spray/diameter", diameter() );
+ Q_UNUSED(setting);
}
// TODO
void KisSprayShapeOption::readOptionSetting(const KisPropertiesConfiguration* setting)
{
- /* m_options->diameterSpinBox->setValue( setting->getInt("Spray/diameter") );
- m_options->coverageSpin->setValue( setting->getDouble("Spray/coverage") );
- m_options->jitterSizeBox->setChecked( setting->getBool("Spray/jitterSize") );*/
+ Q_UNUSED(setting);
}
@@ -178,4 +192,53 @@
m_options->heightSpin->setValue( m_image.height() );
}
}
-}
\ No newline at end of file
+}
+
+
+void KisSprayShapeOption::aspectToggled(bool toggled)
+{
+ m_useAspect = toggled;
+ KoImageResource kir;
+ if (toggled){
+ m_options->btnAspect->setIcon(QIcon(kir.chain()));
+ } else {
+ m_options->btnAspect->setIcon(QIcon(kir.chainBroken()));
+ }
+}
+
+
+
+void KisSprayShapeOption::updateHeight(int value)
+{
+ if (m_useAspect){
+ int newHeight = qRound(value * 1.0/m_aspect);
+ m_options->heightSpin->blockSignals(true);
+ m_options->heightSpin->setValue(newHeight);
+ m_options->heightSlider->setValue(newHeight);
+ m_options->heightSpin->blockSignals(false);
+ }else{
+ computeAspect();
+ }
+}
+
+
+void KisSprayShapeOption::updateWidth(int value)
+{
+ if (m_useAspect){
+ int newWidth = qRound(value * m_aspect);
+ m_options->widthSpin->blockSignals(true);
+ m_options->widthSpin->setValue( newWidth );
+ m_options->widthSlider->setValue( newWidth );
+ m_options->widthSpin->blockSignals(false);
+ }else{
+ computeAspect();
+ }
+}
+
+
+void KisSprayShapeOption::computeAspect()
+{
+ qreal w = m_options->widthSpin->value();
+ qreal h = m_options->heightSpin->value();
+ m_aspect = w / h;
+}
--- trunk/koffice/krita/plugins/paintops/spray/kis_spray_shape_option.h #1058074:1058075
@@ -43,6 +43,7 @@
qreal heightPerc() const;
int width() const;
int height() const;
+
/// random size
bool jitterShapeSize() const;
@@ -63,11 +64,20 @@
private:
KisShapeOptionsWidget * m_options;
QImage m_image;
+ bool m_useAspect;
+ qreal m_aspect;
+
+private:
+ void setupBrushPreviewSignals();
+ void computeAspect();
private slots:
void randomValueChanged(int value);
void followValueChanged(int value);
void prepareImage();
+ void aspectToggled(bool toggled);
+ void updateHeight(int value);
+ void updateWidth(int value);
};
#endif // KIS_SPRAY_SHAPE_OPTION_H
--- trunk/koffice/krita/plugins/paintops/spray/wdgshapeoptions.ui #1058074:1058075
@@ -9,7 +9,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>425</width>
+ <width>488</width>
<height>365</height>
</rect>
</property>
@@ -229,7 +229,7 @@
<x>10</x>
<y>100</y>
<width>401</width>
- <height>58</height>
+ <height>62</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
@@ -268,7 +268,58 @@
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
- <x>13</x>
+ <x>10</x>
+ <y>170</y>
+ <width>401</width>
+ <height>25</height>
+ </rect>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QCheckBox" name="jitterShape">
+ <property name="text">
+ <string>Random size</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="gaussBox">
+ <property name="text">
+ <string>gauss distribution</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="layoutWidget">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>330</y>
+ <width>401</width>
+ <height>30</height>
+ </rect>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Texture</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="KUrlRequester" name="imageUrl"/>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="layoutWidget">
+ <property name="geometry">
+ <rect>
+ <x>14</x>
<y>40</y>
<width>401</width>
<height>62</height>
@@ -284,8 +335,11 @@
</item>
<item row="0" column="1">
<widget class="QSlider" name="widthSlider">
+ <property name="minimum">
+ <number>1</number>
+ </property>
<property name="maximum">
- <number>999</number>
+ <number>1000</number>
</property>
<property name="pageStep">
<number>100</number>
@@ -303,14 +357,48 @@
<property name="enabled">
<bool>false</bool>
</property>
+ <property name="minimum">
+ <number>1</number>
+ </property>
<property name="maximum">
- <number>999</number>
+ <number>1000</number>
</property>
<property name="value">
<number>6</number>
</property>
</widget>
</item>
+ <item row="0" column="3" rowspan="2">
+ <widget class="QToolButton" name="btnAspect">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>16</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>16</width>
+ <height>32767</height>
+ </size>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
<item row="1" column="0">
<widget class="QLabel" name="heightInfoLbl">
<property name="text">
@@ -320,8 +408,11 @@
</item>
<item row="1" column="1">
<widget class="QSlider" name="heightSlider">
+ <property name="minimum">
+ <number>1</number>
+ </property>
<property name="maximum">
- <number>999</number>
+ <number>1000</number>
</property>
<property name="pageStep">
<number>100</number>
@@ -339,8 +430,11 @@
<property name="enabled">
<bool>false</bool>
</property>
+ <property name="minimum">
+ <number>1</number>
+ </property>
<property name="maximum">
- <number>999</number>
+ <number>1000</number>
</property>
<property name="value">
<number>6</number>
@@ -349,57 +443,6 @@
</item>
</layout>
</widget>
- <widget class="QWidget" name="layoutWidget">
- <property name="geometry">
- <rect>
- <x>10</x>
- <y>170</y>
- <width>401</width>
- <height>25</height>
- </rect>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QCheckBox" name="jitterShape">
- <property name="text">
- <string>Random size</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="gaussBox">
- <property name="text">
- <string>gauss distribution</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="layoutWidget">
- <property name="geometry">
- <rect>
- <x>10</x>
- <y>330</y>
- <width>401</width>
- <height>28</height>
- </rect>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Texture</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KUrlRequester" name="imageUrl"/>
- </item>
- </layout>
- </widget>
</widget>
<customwidgets>
<customwidget>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic