chalk

kis_layerbox.cpp
1/*
2 * kis_layerbox.cpp - part of Chalk aka Krayon aka KimageShop
3 *
4 * Copyright (c) 2002 Patrick Julien <freak@codepimps.org>
5 * Copyright (C) 2006 Gábor Lehel <illissius@gmail.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 */
21
22#include <tqbutton.h>
23#include <tqtoolbutton.h>
24#include <tqbrush.h>
25#include <tqfont.h>
26#include <tqfontmetrics.h>
27#include <tqhbox.h>
28#include <tqlayout.h>
29#include <tqpainter.h>
30#include <tqpoint.h>
31#include <tqrect.h>
32#include <tqstring.h>
33#include <tqstyle.h>
34#include <tqtooltip.h>
35#include <tqwidget.h>
36#include <tqcombobox.h>
37#include <tqcheckbox.h>
38
39#include <kdebug.h>
40#include <tdeglobal.h>
41#include <tdepopupmenu.h>
42#include <tdemessagebox.h>
43#include <kpushbutton.h>
44#include <kiconloader.h>
45#include <kicontheme.h>
46#include <tdelocale.h>
47
48#include <KoPartSelectAction.h>
49
50#include "kis_layerlist.h"
51#include "kis_cmb_composite.h"
52#include "kis_int_spinbox.h"
53#include "wdglayerbox.h"
54#include "kis_colorspace.h"
55#include "kis_paint_device.h"
56#include "kis_layer.h"
57#include "kis_group_layer.h"
58#include "kis_image.h"
59
60#include "kis_populate_visitor.h"
61
62#include "kis_layerbox.h"
63
64KisLayerBox::KisLayerBox(KisCanvasSubject *subject, TQWidget *parent, const char *name)
65 : super(parent, name), m_image(0)
66{
67 TQVBoxLayout *vbox = new TQVBoxLayout(this);
68 vbox->setAutoAdd(true);
69
70 m_lst = new WdgLayerBox(this);
71 setMinimumSize(m_lst->minimumSizeHint());
72
73 TQToolTip::add(m_lst->bnAdd, i18n("Create new layer"));
74
75 TQToolTip::add(m_lst->bnDelete, i18n("Remove current layer"));
76
77 TQToolTip::add(m_lst->bnRaise, i18n("Raise current layer"));
78 m_lst->bnRaise->setEnabled(false);
79
80 m_lst->bnLower->setEnabled(false);
81 TQToolTip::add(m_lst->bnLower, i18n("Lower current layer"));
82
83 TQToolTip::add(m_lst->bnProperties, i18n("Properties for layer"));
84
85 TDEIconLoader il( "chalk" );
86
87 list()->setPreviewsShown(true);
88
89 list()->setFoldersCanBeActive(true);
90
91 list()->addProperty("visible", i18n("Visible"), loadPixmap("visible.png", il, TDEIcon::SizeSmallMedium),
92 loadPixmap("novisible.png", il, TDEIcon::SizeSmallMedium), true);
93
94 list()->addProperty("locked", i18n("Locked"), loadPixmap("locked.png", il, TDEIcon::SizeSmallMedium),
95 loadPixmap("unlocked.png", il, TDEIcon::SizeSmallMedium));
96
97
98 connect(list()->contextMenu(), TQ_SIGNAL(aboutToShow()), TQ_SLOT(slotAboutToShow()));
99 connect(list(), TQ_SIGNAL(activated(LayerItem*)),
100 TQ_SLOT(slotLayerActivated(LayerItem*)));
101 connect(list(), TQ_SIGNAL(displayNameChanged(LayerItem*, const TQString&)),
102 TQ_SLOT(slotLayerDisplayNameChanged(LayerItem*, const TQString&)));
103 connect(list(), TQ_SIGNAL(propertyChanged(LayerItem*, const TQString&, bool)),
104 TQ_SLOT(slotLayerPropertyChanged(LayerItem*, const TQString&, bool)));
105 connect(list(), TQ_SIGNAL(layerMoved(LayerItem*, LayerItem*, LayerItem*)),
106 TQ_SLOT(slotLayerMoved(LayerItem*, LayerItem*, LayerItem*)));
107 connect(list(), TQ_SIGNAL(requestNewLayer(LayerItem*, LayerItem*)),
108 TQ_SLOT(slotRequestNewLayer(LayerItem*, LayerItem*)));
109 connect(list(), TQ_SIGNAL(requestNewFolder(LayerItem*, LayerItem*)),
110 TQ_SLOT(slotRequestNewFolder(LayerItem*, LayerItem*)));
111 connect(list(), TQ_SIGNAL(requestNewAdjustmentLayer(LayerItem*, LayerItem*)),
112 TQ_SLOT(slotRequestNewAdjustmentLayer(LayerItem*, LayerItem*)));
113 connect(list(), TQ_SIGNAL(requestNewObjectLayer(LayerItem*, LayerItem*, const KoDocumentEntry&)),
114 TQ_SLOT(slotRequestNewObjectLayer(LayerItem*, LayerItem*, const KoDocumentEntry&)));
115 connect(list(), TQ_SIGNAL(requestRemoveLayer(LayerItem*)),
116 TQ_SLOT(slotRequestRemoveLayer(LayerItem*)));
117 connect(list(), TQ_SIGNAL(requestLayerProperties(LayerItem*)),
118 TQ_SLOT(slotRequestLayerProperties(LayerItem*)));
119
120 m_newLayerMenu = new TDEPopupMenu(this);
121 m_lst->bnAdd->setPopup(m_newLayerMenu);
122 m_lst->bnAdd->setPopupDelay(1);
123 m_newLayerMenu->insertItem( SmallIconSet( "document-new" ), i18n( "&New Layer..." ), PAINT_LAYER );
124 m_newLayerMenu->insertItem( SmallIconSet( "folder" ), i18n( "New &Group Layer..." ), GROUP_LAYER );
125 m_newLayerMenu->insertItem( SmallIconSet( "tool_filter" ), i18n( "New &Adjustment Layer..." ), ADJUSTMENT_LAYER );
126 m_partLayerAction = new KoPartSelectAction( i18n( "New &Object Layer" ), "gear", this );
127 m_partLayerAction->plug( m_newLayerMenu );
128 connect(m_partLayerAction, TQ_SIGNAL(activated()), this, TQ_SLOT(slotAddMenuActivated()));
129 connect(m_newLayerMenu, TQ_SIGNAL(activated(int)), this, TQ_SLOT(slotAddMenuActivated(int)));
130
131
132 connect(m_lst->bnDelete, TQ_SIGNAL(clicked()), TQ_SLOT(slotRmClicked()));
133 connect(m_lst->bnRaise, TQ_SIGNAL(clicked()), TQ_SLOT(slotRaiseClicked()));
134 connect(m_lst->bnLower, TQ_SIGNAL(clicked()), TQ_SLOT(slotLowerClicked()));
135 connect(m_lst->bnProperties, TQ_SIGNAL(clicked()), TQ_SLOT(slotPropertiesClicked()));
136 connect(m_lst->intOpacity, TQ_SIGNAL(valueChanged(int, bool)), TQ_SIGNAL(sigOpacityChanged(int, bool)));
137 connect(m_lst->intOpacity, TQ_SIGNAL(finishedChanging(int, int)), TQ_SIGNAL(sigOpacityFinishedChanging(int, int)));
138 connect(m_lst->cmbComposite, TQ_SIGNAL(activated(const KisCompositeOp&)), TQ_SIGNAL(sigItemComposite(const KisCompositeOp&)));
139
140 Q_ASSERT(subject->document() != 0);
141
142 if (subject->document()) {
143 connect(subject->document(), TQ_SIGNAL(sigCommandExecuted()), TQ_SLOT(updateThumbnails()));
144 }
145}
146
147KisLayerBox::~KisLayerBox()
148{
149}
150
151KisLayerList* KisLayerBox::list() const
152{
153 return m_lst->listLayers;
154}
155
156void KisLayerBox::setImage(KisImageSP img)
157{
158 if (m_image == img)
159 return;
160
161 if (m_image)
162 m_image->disconnect(this);
163
164 m_image = img;
165
166 if (img)
167 {
168 connect(img, TQ_SIGNAL(sigLayerActivated(KisLayerSP)), this, TQ_SLOT(slotLayerActivated(KisLayerSP)));
169 connect(img, TQ_SIGNAL(sigLayerAdded(KisLayerSP)), this, TQ_SLOT(slotLayerAdded(KisLayerSP)));
170 connect(img, TQ_SIGNAL(sigLayerRemoved(KisLayerSP, KisGroupLayerSP, KisLayerSP)),
171 this, TQ_SLOT(slotLayerRemoved(KisLayerSP, KisGroupLayerSP, KisLayerSP)));
172 connect(img, TQ_SIGNAL(sigLayerPropertiesChanged(KisLayerSP)),
173 this, TQ_SLOT(slotLayerPropertiesChanged(KisLayerSP)));
174 connect(img, TQ_SIGNAL(sigLayerMoved(KisLayerSP, KisGroupLayerSP, KisLayerSP)),
175 this, TQ_SLOT(slotLayerMoved(KisLayerSP, KisGroupLayerSP, KisLayerSP)));
176 connect(img, TQ_SIGNAL(sigLayersChanged(KisGroupLayerSP)), this, TQ_SLOT(slotLayersChanged(KisGroupLayerSP)));
177 connect(img, TQ_SIGNAL(sigLayerUpdated(KisLayerSP, TQRect)), this, TQ_SLOT(slotLayerUpdated(KisLayerSP, TQRect)));
178 slotLayersChanged(img->rootLayer());
179 updateThumbnails();
180 }
181 else
182 {
183 clear();
184 }
185}
186
187void KisLayerBox::slotLayerActivated(KisLayerSP layer)
188{
189 if (layer)
190 list()->setActiveLayer(layer->id());
191 else
192 list()->setActiveLayer(-1);
193 updateUI();
194}
195
196void KisLayerBox::slotLayerAdded(KisLayerSP layer)
197{
198 if (layer.data() == m_image->rootLayer().data() || list()->layer(layer->id()))
199 return;
200
201 vKisLayerSP layersAdded;
202
203 if (layer->parent() == m_image->rootLayer())
204 {
205 KisPopulateVisitor visitor(list());
206 layer->accept(visitor);
207 layersAdded = visitor.layersAdded();
208 }
209 else
210 {
211 KisPopulateVisitor visitor(static_cast<KisLayerItem*>(list()->layer(layer->parent()->id())));
212 layer->accept(visitor);
213 layersAdded = visitor.layersAdded();
214 }
215
216 for (vKisLayerSP::iterator it = layersAdded.begin(); it != layersAdded.end(); ++it) {
217 markModified(*it);
218 }
219 updateUI();
220}
221
222void KisLayerBox::slotLayerRemoved(KisLayerSP layer, KisGroupLayerSP wasParent, KisLayerSP)
223{
224 list()->removeLayer(layer->id());
225 m_modified.remove(layer->id());
226 markModified(wasParent);
227 updateUI();
228}
229
230void KisLayerBox::slotLayerMoved(KisLayerSP layer, KisGroupLayerSP wasParent, KisLayerSP)
231{
232 int parentID = layer->parent()->id();
233 if (layer->parent() == m_image->rootLayer())
234 parentID = -1;
235
236 int siblingID = -1;
237 if (layer->prevSibling())
238 siblingID = layer->prevSibling()->id();
239
240 list()->moveLayer(layer->id(), parentID, siblingID);
241
242 markModified(layer->parent());
243 markModified(wasParent);
244 updateUI();
245}
246
247void KisLayerBox::slotLayerPropertiesChanged(KisLayerSP layer)
248{
249 if (KisLayerItem* item = dynamic_cast<KisLayerItem*>(list()->layer(layer->id())))
250 {
251 Q_ASSERT(item->layer() == layer.data());
252 item->sync();
253 updateUI();
254 markModified(layer);
255 }
256}
257
258void KisLayerBox::slotLayersChanged(KisGroupLayerSP rootLayer)
259{
260 list()->clear();
261 KisPopulateVisitor visitor(list());
262 for (KisLayerSP layer = rootLayer->firstChild(); layer; layer = layer->nextSibling())
263 layer->accept(visitor);
264 m_modified.clear();
265 for (TQListViewItemIterator it(list()->lastItem()); *it; --it)
266 m_modified.append(static_cast<LayerItem*>(*it)->id());
267 updateUI();
268}
269
270void KisLayerBox::slotLayerUpdated(KisLayerSP layer, TQRect)
271{
272 markModified(layer);
273}
274
275void KisLayerBox::slotLayerActivated(LayerItem* item)
276{
277 if (item)
278 m_image->activate(m_image->findLayer(item->id()));
279 else
280 m_image->activate(0);
281 updateUI();
282}
283
284void KisLayerBox::slotLayerDisplayNameChanged(LayerItem* item, const TQString& displayName)
285{
286 if(KisLayerSP layer = m_image->findLayer(item->id()))
287 layer->setName(displayName);
288 updateUI();
289}
290
291void KisLayerBox::slotLayerPropertyChanged(LayerItem* item, const TQString& name, bool on)
292{
293 if (KisLayerSP layer = m_image->findLayer(item->id()))
294 {
295 if (name == "visible")
296 layer->setVisible(on);
297 else if (name == "locked")
298 layer->setLocked(on);
299 }
300}
301
302void KisLayerBox::slotLayerMoved(LayerItem* item, LayerItem*, LayerItem*)
303{
304 KisLayerSP layer = m_image->findLayer(item->id());
305 KisGroupLayerSP parent;
306 if( item->parent() )
307 parent = dynamic_cast<KisGroupLayer*>(m_image->findLayer(item->parent()->id()).data());
308 if( !parent )
309 parent = m_image->rootLayer();
310 KisLayerSP above = 0;
311 if (item->nextSibling())
312 above = m_image->findLayer(item->nextSibling()->id());
313 if (layer)
314 m_image->moveLayer(layer, parent.data(), above);
315 updateUI();
316}
317
318void KisLayerBox::slotRequestNewLayer(LayerItem* p, LayerItem* after)
319{
320 KisLayer* l = m_image->rootLayer().data();
321 if (p)
322 l = m_image->findLayer(p->id()).data();
323 KisGroupLayerSP parent = dynamic_cast<KisGroupLayer*>(l);
324
325 KisLayerSP above = 0;
326 if (after && after->nextSibling())
327 above = m_image->findLayer(after->nextSibling()->id());
328 else if (after)
329 above = 0;
330 else if (p && p->firstChild())
331 above = parent->firstChild();
332 else if (!p && m_image->rootLayer()->childCount())
333 above = m_image->rootLayer()->firstChild();
334 emit sigRequestLayer(parent, above);
335}
336
337void KisLayerBox::slotRequestNewFolder(LayerItem* p, LayerItem* after)
338{
339 KisLayer* l = m_image->rootLayer().data(); //FIXME I hate copy-pasting like this.
340 if (p)
341 l = m_image->findLayer(p->id()).data();
342 KisGroupLayerSP parent = dynamic_cast<KisGroupLayer*>(l);
343
344 KisLayerSP above = 0;
345 if (after && after->nextSibling())
346 above = m_image->findLayer(after->nextSibling()->id());
347 else if (after)
348 above = 0;
349 else if (p && p->firstChild())
350 above = parent->firstChild();
351 else if (!p && m_image->rootLayer()->childCount())
352 above = m_image->rootLayer()->firstChild();
353 emit sigRequestGroupLayer(parent, above);
354}
355
356void KisLayerBox::slotRequestNewAdjustmentLayer(LayerItem* p, LayerItem* after)
357{
358 KisLayer* l = m_image->rootLayer().data(); //FIXME here too.
359 if (p)
360 l = m_image->findLayer(p->id()).data();
361 KisGroupLayerSP parent = dynamic_cast<KisGroupLayer*>(l);
362
363 KisLayerSP above = 0;
364 if (after && after->nextSibling())
365 above = m_image->findLayer(after->nextSibling()->id());
366 else if (after)
367 above = 0;
368 else if (p && p->firstChild())
369 above = parent->firstChild();
370 else if (!p && m_image->rootLayer()->childCount())
371 above = m_image->rootLayer()->firstChild();
372 emit sigRequestAdjustmentLayer(parent, above);
373}
374
375void KisLayerBox::slotRequestNewObjectLayer(LayerItem* p, LayerItem* after, const KoDocumentEntry& entry)
376{
377 KisLayer* l = m_image->rootLayer().data(); //FIXME and here.
378 if (p)
379 l = m_image->findLayer(p->id()).data();
380 KisGroupLayerSP parent = dynamic_cast<KisGroupLayer*>(l);
381
382 KisLayerSP above = 0;
383 if (after && after->nextSibling())
384 above = m_image->findLayer(after->nextSibling()->id());
385 else if (after)
386 above = 0;
387 else if (p && p->firstChild())
388 above = parent->firstChild();
389 else if (!p && m_image->rootLayer()->childCount())
390 above = m_image->rootLayer()->firstChild();
391 emit sigRequestPartLayer(parent, above, entry);
392}
393
394void KisLayerBox::slotRequestRemoveLayer(LayerItem* item)
395{
396 if (KisLayerSP layer = m_image->findLayer(item->id())) {
397 m_image->removeLayer(layer);
398 }
399 updateUI();
400}
401
402void KisLayerBox::slotRequestLayerProperties(LayerItem* item)
403{
404 if (KisLayerSP layer = m_image->findLayer(item->id()))
405 {
406 emit sigRequestLayerProperties(layer);
407 }
408}
409
410void KisLayerBox::updateUI()
411{
412 m_lst->bnDelete->setEnabled(list()->activeLayer());
413 m_lst->bnRaise->setEnabled(list()->activeLayer() && (list()->activeLayer()->prevSibling() || list()->activeLayer()->parent()));
414 m_lst->bnLower->setEnabled(list()->activeLayer() && list()->activeLayer()->nextSibling());
415 m_lst->intOpacity->setEnabled(list()->activeLayer());
416 m_lst->cmbComposite->setEnabled(list()->activeLayer());
417 if (m_image)
418 if (KisLayerSP active = m_image->activeLayer())
419 {
420 if (m_image->activeDevice())
421 slotSetColorSpace(m_image->activeDevice()->colorSpace());
422 else
423 slotSetColorSpace(m_image->colorSpace());
424 slotSetOpacity(int(float(active->opacity() * 100) / 255 + 0.5));
425 slotSetCompositeOp(active->compositeOp());
426 }
427}
428
429void KisLayerBox::slotAboutToShow()
430{
431}
432
433void KisLayerBox::slotSetCompositeOp(const KisCompositeOp& compositeOp)
434{
435 m_lst->cmbComposite->blockSignals(true);
436 m_lst->cmbComposite->setCurrentItem(compositeOp);
437 m_lst->cmbComposite->blockSignals(false);
438}
439
440void KisLayerBox::slotSetColorSpace(const KisColorSpace * colorSpace)
441{
442 m_lst->cmbComposite->blockSignals(true);
443 m_lst->cmbComposite->setCompositeOpList(colorSpace->userVisiblecompositeOps());
444 m_lst->cmbComposite->blockSignals(false);
445}
446
447// range: 0-100
448void KisLayerBox::slotSetOpacity(int opacity)
449{
450 m_lst->intOpacity->blockSignals(true);
451 m_lst->intOpacity->setValue(opacity);
452 m_lst->intOpacity->blockSignals(false);
453}
454
455void KisLayerBox::clear()
456{
457 list()->clear();
458 updateUI();
459}
460
461void KisLayerBox::slotAddMenuActivated(int type)
462{
463 if(type == -1)
464 return;
465
466 KisGroupLayerSP root = m_image->rootLayer();
467 KisGroupLayerSP parent;
468 KisLayerSP above;
469 if (KisLayerSP active = m_image->activeLayer())
470 {
471 parent = root;
472 above = active;
473 if (active->parent())
474 parent = active->parent();
475 }
476 else
477 {
478 parent = root;
479 above = m_image->rootLayer()->firstChild();
480 }
481
482 switch (type)
483 {
484 case PAINT_LAYER:
485 emit sigRequestLayer(parent, above);
486 break;
487 case GROUP_LAYER:
488 emit sigRequestGroupLayer(parent, above);
489 break;
490 case ADJUSTMENT_LAYER:
491 emit sigRequestAdjustmentLayer(parent, above);
492 break;
493 case OBJECT_LAYER:
494 default: //TQt doesn't emit activated for default-assigned IDs, so this does nothing
495 emit sigRequestPartLayer(parent, above, m_partLayerAction->documentEntry());
496 }
497}
498
499void KisLayerBox::slotRmClicked()
500{
501 TQValueList<int> l = list()->selectedLayerIDs();
502 if (l.count() < 2 && list()->activeLayer() && !l.contains(list()->activeLayer()->id()))
503 {
504 l.clear();
505 l.append(list()->activeLayer()->id());
506 }
507
508 for (int i = 0, n = l.count(); i < n; ++i)
509 {
510 m_modified.remove(l[i]);
511 m_image->removeLayer(m_image->findLayer(l[i]));
512 }
513}
514
515void KisLayerBox::slotRaiseClicked()
516{
517 TQValueList<int> l = list()->selectedLayerIDs();
518 if (l.count() < 2 && list()->activeLayer() && !l.contains(list()->activeLayer()->id()))
519 {
520 l.clear();
521 l.append(list()->activeLayer()->id());
522 }
523
524 KisLayerSP layer = m_image->findLayer(l.first());
525 if( l.count() == 1 && layer == layer->parent()->firstChild() && layer->parent() != m_image->rootLayer())
526 {
527 if (KisGroupLayerSP grandparent = layer->parent()->parent())
528 m_image->moveLayer(layer, grandparent, layer->parent().data());
529 }
530 else
531 {
532 for (int i = 0, n = l.count(); i < n; ++i)
533 if (KisLayerSP li = m_image->findLayer(l[i]))
534 if (li->prevSibling())
535 m_image->moveLayer(li, li->parent(), li->prevSibling());
536 }
537
538 if( !l.isEmpty() )
539 list()->ensureItemVisible( list()->layer( l.first() ) );
540}
541
542void KisLayerBox::slotLowerClicked()
543{
544 TQValueList<LayerItem*> l = list()->selectedLayers();
545 if (l.count() < 2 && list()->activeLayer() && !l.contains(list()->activeLayer()))
546 {
547 l.clear();
548 l.append(list()->activeLayer());
549 }
550
551 for (int i = l.count() - 1; i >= 0; --i)
552 if (LayerItem *layer = l[i])
553 if (layer->nextSibling())
554 list()->moveLayer(layer, layer->parent(), layer->nextSibling());
555
556 if( !l.isEmpty() )
557 list()->ensureItemVisible( l.last() );
558}
559
560void KisLayerBox::slotPropertiesClicked()
561{
562 if (KisLayerSP active = m_image->activeLayer())
563 emit sigRequestLayerProperties(active);
564}
565
566void KisLayerBox::updateThumbnails()
567{
568 bool again = true;
569 while (m_modified.count() && again)
570 {
571 //again = false;
572 KisLayerItem* item = static_cast<KisLayerItem*>(list()->layer(m_modified.last()));
573 m_modified.pop_back();
574 if (!item || !item->updatePreview())
575 again = true;
576 }
577}
578
579void KisLayerBox::setUpdatesAndSignalsEnabled(bool enable)
580{
581 setUpdatesEnabled(enable);
582 m_lst->intOpacity->setUpdatesEnabled(enable);
583 m_lst->cmbComposite->setUpdatesEnabled(enable);
584
585 list()->blockSignals(!enable);
586 m_lst->intOpacity->blockSignals(!enable);
587 m_lst->cmbComposite->blockSignals(!enable);
588}
589
590
591TQPixmap KisLayerBox::loadPixmap(const TQString& filename, const TDEIconLoader&
592 il, int size)
593{
594 TQPixmap pixmap = il.loadIcon(filename, TDEIcon::NoGroup, size);
595
596 if (pixmap.isNull())
597 KMessageBox::error(0, i18n("Cannot find %1").arg(filename),
598 i18n("Canvas"));
599
600 return pixmap;
601}
602
603void KisLayerBox::markModified(KisLayer* layer)
604{
605 if( !layer )
606 return;
607
608 TQValueList<int> v;
609 while (layer && layer != m_image->rootLayer().data())
610 {
611 v.append(layer->id());
612 layer = layer->parent();
613 }
614 for (int i = v.count() - 1; i >= 0; --i)
615 if (!m_modified.contains(v[i]))
616 m_modified.append(v[i]);
617}
618
619void KisLayerBox::printChalkLayers() const
620{
621 static int indent = 0;
622 static KisLayer *root = 0;
623 if( !root )
624 root = m_image->rootLayer();
625 if( !root )
626 return;
627 TQString s = root->name();
628 if( dynamic_cast<KisGroupLayer*>( root ) )
629 s = TQString("[%1]").arg( s );
630 if( m_image->activeLayer().data() == root )
631 s.prepend("*");
632 kdDebug() << (TQString().fill(' ', indent) + s) << endl;
633 for (KisLayer* layer = root->firstChild(); layer; layer = layer->nextSibling())
634 {
635 indent += 2;
636 root = layer;
637 printChalkLayers();
638 indent -= 2;
639 root = layer->parent();
640 }
641}
642
643void KisLayerBox::printLayerboxLayers() const
644{
645 static int indent = 0;
646 static LayerItem *root = 0;
647 if( !root )
648 {
649 for (LayerItem* layer = list()->firstChild(); layer; layer = layer->nextSibling())
650 {
651 indent += 2;
652 root = layer;
653 printLayerboxLayers();
654 indent -= 2;
655 root = layer->parent();
656 }
657 return;
658 }
659 TQString s = root->displayName();
660 if( root->isFolder() )
661 s = TQString("[%1]").arg( s );
662 if( list()->activeLayer() == root )
663 s.prepend("*");
664 kdDebug() << (TQString().fill(' ', indent) + s) << endl;
665 for (LayerItem* layer = root->firstChild(); layer; layer = layer->nextSibling())
666 {
667 indent += 2;
668 root = layer;
669 printLayerboxLayers();
670 indent -= 2;
671 root = layer->parent();
672 }
673}
674
675#include "kis_layerbox.moc"
KisCanvasSubject is part of the Observer pattern.
virtual KisDoc * document() const =0
XXX: Remove this method.
A colorspace is the definition of a certain color model in Chalk.
virtual KisCompositeOpList userVisiblecompositeOps() const =0
Returns the list of user-visible composite ops supported by this colourspace.
Abstract class that represents the concept of a Layer in Chalk.
Definition kis_layer.h:42
virtual KisLayerSP nextSibling() const
Returns the next sibling of this layer in the parent's list.
int id() const
Returns the ID of the layer, which is guaranteed to be unique among all KisLayers.
Definition kis_layer.h:88
virtual KisLayerSP firstChild() const
Returns the first child layer of this layer (if it supports that).
Definition kis_layer.h:133
virtual KisLayerSP findLayer(const TQString &name) const
Recursively searches this layer and any child layers for a layer with the specified name.
virtual KisGroupLayerSP parent() const
Returns the parent layer of a layer.