[kde-doc-english] [calligra] krita/plugins/tools/tool_dyna: Improve the GUI of dyna tool

Lukáš Tvrdý lukast.dev at gmail.com
Sat Nov 5 21:16:38 UTC 2011


Git commit 913936d64bbe1b6737353458220bb1817821a760 by Lukáš Tvrdý.
Committed on 04/11/2011 at 16:07.
Pushed by lukast into branch 'master'.

Improve the GUI of dyna tool

Angle:
User had to compute asin and acos of the angle
before doing input for angle. Not very intuitive.

GUI:
Group together related options

Note: angle is not doing anything so far, that's bug

Removing two strings in string freeze
CCMAIL:kde-i18n-doc at kde.org

M  +29   -40   krita/plugins/tools/tool_dyna/kis_tool_dyna.cpp
M  +6    -8    krita/plugins/tools/tool_dyna/kis_tool_dyna.h

http://commits.kde.org/calligra/913936d64bbe1b6737353458220bb1817821a760

diff --git a/krita/plugins/tools/tool_dyna/kis_tool_dyna.cpp b/krita/plugins/tools/tool_dyna/kis_tool_dyna.cpp
index f3914a4..7a5d4ab 100644
--- a/krita/plugins/tools/tool_dyna/kis_tool_dyna.cpp
+++ b/krita/plugins/tools/tool_dyna/kis_tool_dyna.cpp
@@ -1,7 +1,7 @@
 /*
  *  kis_tool_dyna.cpp - part of Krita
  *
- *  Copyright (c) 2009 Lukáš Tvrdý <LukasT.dev at gmail.com>
+ *  Copyright (c) 2009-2011 Lukáš Tvrdý <LukasT.dev at gmail.com>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -28,6 +28,7 @@
 #include "KoPointerEvent.h"
 
 #include "kis_cursor.h"
+#include <kis_slider_spin_box.h>
 
 
 #define MAXIMUM_SMOOTHNESS 1000
@@ -37,7 +38,6 @@ KisToolDyna::KisToolDyna(KoCanvasBase * canvas)
         : KisToolFreehand(canvas, KisCursor::load("tool_freehand_cursor.png", 5, 5), i18nc("(qtundo-format)", "Dyna"))
 {
     setObjectName("tool_dyna");
-
     initDyna();
 }
 
@@ -247,21 +247,10 @@ void KisToolDyna::slotSetWidthRange(double widthRange)
 }
 
 
-void KisToolDyna::slotSetXangle(double angle)
-{
-    m_xangle = angle;
-}
-
-
-void KisToolDyna::slotSetYangle(double angle)
-{
-    m_yangle = angle;
-}
-
-
 void KisToolDyna::slotSetFixedAngle(bool fixedAngle)
 {
     m_mouse.fixedangle = fixedAngle;
+    m_angleDSSBox->setEnabled(fixedAngle);
 }
 
 QWidget * KisToolDyna::createOptionWidget()
@@ -273,29 +262,31 @@ QWidget * KisToolDyna::createOptionWidget()
     QLabel* initWidthLbl = new QLabel(i18n("Initial width:"), optionWidget);
     QLabel* massLbl = new QLabel(i18n("Mass:"), optionWidget);
     QLabel* dragLbl = new QLabel(i18n("Drag:"), optionWidget);
-    QLabel* xAngleLbl = new QLabel(i18n("X angle:"), optionWidget);
-    QLabel* yAngleLbl = new QLabel(i18n("Y angle:"), optionWidget);
     QLabel* widthRangeLbl = new QLabel(i18n("Width range:"), optionWidget);
 
-    m_chkFixedAngle = new QCheckBox(i18n("Fixed angle:"), optionWidget);
-    m_chkFixedAngle->setChecked(false);
-    connect(m_chkFixedAngle, SIGNAL(toggled(bool)), this, SLOT(slotSetFixedAngle(bool)));
-
     m_initWidthSPBox = new QDoubleSpinBox(optionWidget);
     m_initWidthSPBox->setValue(1.5);
     connect(m_initWidthSPBox, SIGNAL(valueChanged(double)), this, SLOT(slotSetDynaWidth(double)));
+
     m_massSPBox = new QDoubleSpinBox(optionWidget);
     m_massSPBox->setValue(0.5);
     connect(m_massSPBox, SIGNAL(valueChanged(double)), this, SLOT(slotSetMass(double)));
+
     m_dragSPBox = new QDoubleSpinBox(optionWidget);
     m_dragSPBox->setValue(0.15);
     connect(m_dragSPBox, SIGNAL(valueChanged(double)), this, SLOT(slotSetDrag(double)));
-    m_xAngleSPBox = new QDoubleSpinBox(optionWidget);
-    m_xAngleSPBox->setValue(0.6);
-    connect(m_xAngleSPBox, SIGNAL(valueChanged(double)), this, SLOT(slotSetXangle(double)));
-    m_yAngleSPBox = new QDoubleSpinBox(optionWidget);
-    m_yAngleSPBox->setValue(0.2);
-    connect(m_yAngleSPBox, SIGNAL(valueChanged(double)), this, SLOT(slotSetYangle(double)));
+
+    m_chkFixedAngle = new QCheckBox(i18n("Fixed angle:"), optionWidget);
+    m_chkFixedAngle->setChecked(false);
+    connect(m_chkFixedAngle, SIGNAL(toggled(bool)), this, SLOT(slotSetFixedAngle(bool)));
+
+    m_angleDSSBox = new KisDoubleSliderSpinBox(optionWidget);
+    m_angleDSSBox->setRange(0,360,0);
+    m_angleDSSBox->setValue(70);
+    m_angleDSSBox->setSuffix(QChar(Qt::Key_degree));
+    m_angleDSSBox->setEnabled(m_chkFixedAngle->isChecked());
+    connect(m_angleDSSBox, SIGNAL(valueChanged(qreal)), this, SLOT(slotSetAngle(qreal)));
+
     m_widthRangeSPBox = new QDoubleSpinBox(optionWidget);
     m_widthRangeSPBox->setValue(0.05);
     connect(m_widthRangeSPBox, SIGNAL(valueChanged(double)), this, SLOT(slotSetWidthRange(double)));
@@ -307,21 +298,19 @@ QWidget * KisToolDyna::createOptionWidget()
     m_optionLayout->setSpacing(2);
 
     KisToolFreehand::addOptionWidgetLayout(m_optionLayout);
-    m_optionLayout->addWidget(initWidthLbl, 5, 0);
-    m_optionLayout->addWidget(m_initWidthSPBox, 5, 1, 1, 2);
-    m_optionLayout->addWidget(massLbl, 6, 0);
-    m_optionLayout->addWidget(m_massSPBox, 6, 1, 1, 2);
-    m_optionLayout->addWidget(dragLbl, 7, 0);
-    m_optionLayout->addWidget(m_dragSPBox, 7, 1, 1, 2);
-    m_optionLayout->addWidget(m_chkFixedAngle, 8, 0);
-    m_optionLayout->addWidget(xAngleLbl, 9, 0);
-    m_optionLayout->addWidget(m_xAngleSPBox, 9, 1, 1, 2);
-    m_optionLayout->addWidget(yAngleLbl, 10, 0);
-    m_optionLayout->addWidget(m_yAngleSPBox, 10, 1, 1, 2);
-    m_optionLayout->addWidget(widthRangeLbl, 11, 0);
-    m_optionLayout->addWidget(m_widthRangeSPBox, 11, 1, 1, 2);
-
+    KisToolFreehand::addOptionWidgetOption(m_massSPBox,massLbl);
+    KisToolFreehand::addOptionWidgetOption(m_dragSPBox,dragLbl);
+    KisToolFreehand::addOptionWidgetOption(m_angleDSSBox,m_chkFixedAngle);
+    KisToolFreehand::addOptionWidgetOption(m_initWidthSPBox,initWidthLbl);
+    KisToolFreehand::addOptionWidgetOption(m_widthRangeSPBox,widthRangeLbl);
     return optionWidget;
 }
 
+void KisToolDyna::slotSetAngle(qreal angle)
+{
+    m_xangle = cos(angle * M_PI/180.0);
+    m_yangle = sin(angle * M_PI/180.0);
+}
+
+
 #include "kis_tool_dyna.moc"
diff --git a/krita/plugins/tools/tool_dyna/kis_tool_dyna.h b/krita/plugins/tools/tool_dyna/kis_tool_dyna.h
index 71a62c7..b53f508 100644
--- a/krita/plugins/tools/tool_dyna/kis_tool_dyna.h
+++ b/krita/plugins/tools/tool_dyna/kis_tool_dyna.h
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2009 Lukáš Tvrdý <lukast.dev at gmail.com>
+ *  Copyright (c) 2009-2011 Lukáš Tvrdý <lukast.dev at gmail.com>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -26,6 +26,7 @@
 
 #include <flake/kis_node_shape.h>
 
+class KisDoubleSliderSpinBox;
 class QCheckBox;
 class QComboBox;
 class QGridLayout;
@@ -81,7 +82,6 @@ public:
     KisToolDyna(KoCanvasBase * canvas);
     virtual ~KisToolDyna();
 
-    // TODO vymyslet GUI
     QWidget * createOptionWidget();
 
     virtual void mousePressEvent(KoPointerEvent *e);
@@ -95,8 +95,7 @@ private slots:
     void slotSetDynaWidth(double width);
     void slotSetMass(double mass);
     void slotSetDrag(double drag);
-    void slotSetXangle(double angle);
-    void slotSetYangle(double angle);
+    void slotSetAngle(qreal angle);
     void slotSetWidthRange(double widthRange);
     void slotSetFixedAngle(bool fixedAngle);
 
@@ -108,11 +107,10 @@ private:
 
     // dyna gui
     QCheckBox * m_chkFixedAngle;
-    QDoubleSpinBox * m_initWidthSPBox;
     QDoubleSpinBox * m_massSPBox;
     QDoubleSpinBox * m_dragSPBox;
-    QDoubleSpinBox * m_xAngleSPBox;
-    QDoubleSpinBox * m_yAngleSPBox;
+    KisDoubleSliderSpinBox * m_angleDSSBox;
+    QDoubleSpinBox * m_initWidthSPBox;
     QDoubleSpinBox * m_widthRangeSPBox;
 
     // dyna algorithm
@@ -124,7 +122,7 @@ private:
 
     qreal m_surfaceWidth;
     qreal m_surfaceHeight;
-    
+
     // settings variables
     qreal m_width;
     qreal m_curmass;



More information about the kde-doc-english mailing list