19#include <KoImageResource.h>
23#include <tqpushbutton.h>
24#include <tqcombobox.h>
25#include <tqcheckbox.h>
27#include <kstandarddirs.h>
28#include <tdetempfile.h>
33#include "kis_paint_device.h"
35#include "kis_imagepipe_brush.h"
36#include "kis_custom_brush.h"
37#include "kis_resource_mediator.h"
38#include "kis_resourceserver.h"
39#include "kis_paint_layer.h"
40#include "kis_group_layer.h"
42KisCustomBrush::KisCustomBrush(TQWidget *parent,
const char* name,
const TQString& caption, KisView* view)
43 : KisWdgCustomBrush(parent, name), m_view(view)
51 preview->setScaledContents(
true);
53 connect(addButton, TQ_SIGNAL(pressed()),
this, TQ_SLOT(slotAddPredefined()));
54 connect(brushButton, TQ_SIGNAL(pressed()),
this, TQ_SLOT(slotUseBrush()));
56 connect(style, TQ_SIGNAL(activated(
int)),
this, TQ_SLOT(slotUpdateCurrentBrush(
int)));
57 connect(colorAsMask, TQ_SIGNAL(stateChanged(
int)),
this, TQ_SLOT(slotUpdateCurrentBrush(
int)));
60KisCustomBrush::~KisCustomBrush() {
64void KisCustomBrush::showEvent(TQShowEvent *) {
65 slotUpdateCurrentBrush(0);
68void KisCustomBrush::slotUpdateCurrentBrush(
int) {
70 if (m_view->canvasSubject() && m_view->canvasSubject()->currentImg()) {
72 preview->setPixmap(TQPixmap(m_brush->img()));
78void KisCustomBrush::slotExport() {
82void KisCustomBrush::slotAddPredefined() {
85 TQString dir = TDEGlobal::dirs()->saveLocation(
"data",
"chalk/brushes");
88 if (style->currentItem() == 0) {
93 KTempFile file(dir, extension);
97 m_brush->setFilename(file.name());
102 m_server->addResource(m_brush->clone());
105void KisCustomBrush::slotUseBrush() {
106 KisBrush* copy = m_brush->clone();
110 emit(activatedResource(copy));
113void KisCustomBrush::createBrush() {
114 KisImageSP img = m_view->canvasSubject()->currentImg();
119 if (style->currentItem() == 0) {
120 m_brush =
new KisBrush(img->mergedImage(), 0, 0, img->width(), img->height());
121 if (colorAsMask->isChecked())
122 m_brush->makeMaskImage();
127 TQValueVector< TQValueVector<KisPaintDevice*> > devices;
128 devices.push_back(TQValueVector<KisPaintDevice*>());
129 int w = img->width();
130 int h = img->height();
134 KisLayer* layer = img->rootLayer()->firstChild();
136 KisPaintLayer* paint = 0;
137 if (layer->visible() && (paint =
dynamic_cast<KisPaintLayer*
>(layer)))
138 devices.at(0).push_back(paint->paintDevice());
141 TQValueVector<KisPipeBrushParasite::SelectionMode> modes;
143 switch(comboBox2->currentItem()) {
144 case 0: modes.push_back(KisPipeBrushParasite::Constant);
break;
145 case 1: modes.push_back(KisPipeBrushParasite::Random);
break;
146 case 2: modes.push_back(KisPipeBrushParasite::Incremental);
break;
147 case 3: modes.push_back(KisPipeBrushParasite::Pressure);
break;
148 case 4: modes.push_back(KisPipeBrushParasite::Angular);
break;
149 default: modes.push_back(KisPipeBrushParasite::Incremental);
152 m_brush =
new KisImagePipeBrush(img->name(), w, h, devices, modes);
153 if (colorAsMask->isChecked())
154 m_brush->makeMaskImage();
158#include "kis_custom_brush.moc"
virtual KisLayerSP nextSibling() const
Returns the next sibling of this layer in the parent's list.