~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to krita/ui/kis_brush_chooser.cc

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2006-04-20 21:38:53 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060420213853-j5lxluqvymxt2zny
Tags: 1:1.5.0-0ubuntu2
UbuntuĀ uploadĀ 

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
 *
14
14
 *  You should have received a copy of the GNU General Public License
15
15
 *  along with this program; if not, write to the Free Software
16
 
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
16
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
 */
18
18
#include <qlabel.h>
19
19
#include <qlayout.h>
27
27
#include "kis_icon_item.h"
28
28
#include "kis_brush.h"
29
29
 
30
 
KisBrushChooser::KisBrushChooser(QWidget *parent, const char *name) : super(parent, name)
 
30
KisBrushChooser::KisBrushChooser(QWidget *parent, const char *name)
 
31
    : super(parent, name)
31
32
{
32
 
        m_lbSpacing = new QLabel(i18n("Spacing: "), this);
33
 
        m_slSpacing = new KisDoubleWidget(0.01, 10, this, "double_widget");
34
 
        m_slSpacing -> setTickmarks(QSlider::Below);
35
 
        m_slSpacing -> setTickInterval(1);
36
 
        QObject::connect(m_slSpacing, SIGNAL(valueChanged(double)), this, SLOT(slotSetItemSpacing(double)));
37
 
 
38
 
        m_chkColorMask = new QCheckBox(i18n("Use color as mask"), this);
39
 
        QObject::connect(m_chkColorMask, SIGNAL(toggled(bool)), this, SLOT(slotSetItemUseColorAsMask(bool)));
40
 
 
41
 
        m_lbName = new QLabel(this);
42
 
 
43
 
        QVBoxLayout *mainLayout = new QVBoxLayout(this, 2, -1, "main layout");
44
 
 
45
 
        mainLayout -> addWidget(m_lbName);
46
 
        mainLayout -> addWidget(chooserWidget(), 10);
47
 
 
48
 
        QGridLayout *spacingLayout = new QGridLayout( 2, 2);
49
 
 
50
 
        mainLayout -> addLayout(spacingLayout, 1);
51
 
 
52
 
        spacingLayout -> addWidget(m_lbSpacing, 0, 0);
53
 
        spacingLayout -> addWidget(m_slSpacing, 0, 1);
54
 
 
55
 
        spacingLayout -> addMultiCellWidget(m_chkColorMask, 1, 1, 0, 1);
 
33
    m_lbSpacing = new QLabel(i18n("Spacing: "), this);
 
34
    m_slSpacing = new KisDoubleWidget(0.0, 10, this, "double_widget");
 
35
    m_slSpacing->setTickmarks(QSlider::Below);
 
36
    m_slSpacing->setTickInterval(1);
 
37
    QObject::connect(m_slSpacing, SIGNAL(valueChanged(double)), this, SLOT(slotSetItemSpacing(double)));
 
38
 
 
39
    m_chkColorMask = new QCheckBox(i18n("Use color as mask"), this);
 
40
    QObject::connect(m_chkColorMask, SIGNAL(toggled(bool)), this, SLOT(slotSetItemUseColorAsMask(bool)));
 
41
 
 
42
    m_lbName = new QLabel(this);
 
43
 
 
44
    QVBoxLayout *mainLayout = new QVBoxLayout(this, 2, -1, "main layout");
 
45
 
 
46
    mainLayout->addWidget(m_lbName);
 
47
    mainLayout->addWidget(chooserWidget(), 10);
 
48
 
 
49
    QGridLayout *spacingLayout = new QGridLayout( 2, 2);
 
50
 
 
51
    mainLayout->addLayout(spacingLayout, 1);
 
52
 
 
53
    spacingLayout->addWidget(m_lbSpacing, 0, 0);
 
54
    spacingLayout->addWidget(m_slSpacing, 0, 1);
 
55
 
 
56
    spacingLayout->addMultiCellWidget(m_chkColorMask, 1, 1, 0, 1);
56
57
}
57
58
 
58
59
KisBrushChooser::~KisBrushChooser()
61
62
 
62
63
void KisBrushChooser::slotSetItemSpacing(double spacingValue)
63
64
{
64
 
        KisIconItem *item = static_cast<KisIconItem *>(currentItem());
 
65
    KisIconItem *item = static_cast<KisIconItem *>(currentItem());
65
66
 
66
 
        if (item) {
67
 
                KisBrush *brush = static_cast<KisBrush *>(item -> resource());
68
 
                brush -> setSpacing(spacingValue);
69
 
        }
 
67
    if (item) {
 
68
        KisBrush *brush = static_cast<KisBrush *>(item->resource());
 
69
        brush->setSpacing(spacingValue);
 
70
    }
70
71
}
71
72
 
72
73
void KisBrushChooser::slotSetItemUseColorAsMask(bool useColorAsMask)
73
74
{
74
 
        KisIconItem *item = static_cast<KisIconItem *>(currentItem());
 
75
    KisIconItem *item = static_cast<KisIconItem *>(currentItem());
75
76
 
76
 
        if (item) {
77
 
                KisBrush *brush = static_cast<KisBrush *>(item -> resource());
78
 
                brush -> setUseColorAsMask(useColorAsMask);
79
 
                item -> updatePixmaps();
80
 
                // The item's pixmaps may have changed so get observers to update
81
 
                // their display.
82
 
                notify();
83
 
        }
 
77
    if (item) {
 
78
        KisBrush *brush = static_cast<KisBrush *>(item->resource());
 
79
        brush->setUseColorAsMask(useColorAsMask);
 
80
        item->updatePixmaps();
 
81
        emit selected(currentItem());
 
82
    }
84
83
}
85
84
 
86
85
void KisBrushChooser::update(KoIconItem *item)
87
86
{
88
 
        KisIconItem *kisItem = static_cast<KisIconItem *>(item);
89
 
 
90
 
        if (kisItem) {
91
 
                KisBrush *brush = static_cast<KisBrush *>(kisItem -> resource());
92
 
 
93
 
                QString text = QString("%1 (%2 x %3)").arg(brush -> name()).arg(brush -> width()).arg(brush -> height());
94
 
 
95
 
                m_lbName -> setText(text);
96
 
                m_slSpacing -> setValue(brush -> spacing());
97
 
                m_chkColorMask -> setChecked(brush -> useColorAsMask());
98
 
                m_chkColorMask -> setEnabled(brush -> hasColor());
99
 
        }
 
87
    KisIconItem *kisItem = static_cast<KisIconItem *>(item);
 
88
 
 
89
    if (kisItem) {
 
90
        KisBrush *brush = static_cast<KisBrush *>(kisItem->resource());
 
91
 
 
92
        QString text = QString("%1 (%2 x %3)").arg(brush->name()).arg(brush->width()).arg(brush->height());
 
93
 
 
94
        m_lbName->setText(text);
 
95
        m_slSpacing->setValue(brush->spacing());
 
96
        m_chkColorMask->setChecked(brush->useColorAsMask());
 
97
        m_chkColorMask->setEnabled(brush->hasColor());
 
98
    }
100
99
}
101
100
 
102
101
#include "kis_brush_chooser.moc"