summaryrefslogtreecommitdiffstats
path: root/chalk/ui/kis_layerbox.h
blob: c9d14a881ec8e1b63017fe1cf84060223d13922f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
 *  kis_layerbox.h - part of Chalk aka Krayon aka KimageShop
 *
 *  Copyright (c) 2002 Patrick Julien <freak@codepimps.org>
 *  Copyright (C) 2006 Gábor Lehel <illissius@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
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#ifndef KIS_LAYERBOX_H
#define KIS_LAYERBOX_H

#include <tqframe.h>
#include <kdebug.h>
#include <tqtimer.h>

#include "kis_types.h"
#include "kis_colorspace.h"

class WdgLayerBox;
class TQButton;
class TQPainter;
class TQWidget;
class KIconLoader;
class KPopupMenu;
class KoDocumentEntry;
class KisCompositeOp;
class KisLayerList;
class LayerItem;
class KisCanvasSubject;

class KisLayerBox : public TQFrame {
        typedef TQFrame super;
        Q_OBJECT
  TQ_OBJECT

public:
    KisLayerBox(KisCanvasSubject *subject, TQWidget *tqparent = 0, const char *name = 0);
    virtual ~KisLayerBox();

    void clear();
    void setUpdatesAndSignalsEnabled(bool enable);
    void setImage(KisImageSP image);

public slots:
    // connect to KisImage signals
    void slotLayerActivated(KisLayerSP layer);
    void slotLayerAdded(KisLayerSP layer);
    void slotLayerRemoved(KisLayerSP layer, KisGroupLayerSP wasParent, KisLayerSP wasAboveThis);
    void slotLayerMoved(KisLayerSP layer, KisGroupLayerSP wasParent, KisLayerSP wasAboveThis);
    void slotLayerPropertiesChanged(KisLayerSP layer);
    void slotLayersChanged(KisGroupLayerSP rootLayer);
    void slotLayerUpdated(KisLayerSP layer, TQRect rc);

    void slotSetCompositeOp(const KisCompositeOp& compositeOp);
    void slotSetOpacity(int opacity);
    void slotSetColorSpace(const KisColorSpace * colorSpace);

signals:
    void sigRequestLayer(KisGroupLayerSP tqparent, KisLayerSP above);
    void sigRequestGroupLayer(KisGroupLayerSP tqparent, KisLayerSP above);
    void sigRequestAdjustmentLayer(KisGroupLayerSP tqparent, KisLayerSP above);
    void sigRequestPartLayer(KisGroupLayerSP tqparent, KisLayerSP above, const KoDocumentEntry& entry);
    void sigRequestLayerProperties(KisLayerSP layer);

    void sigOpacityChanged(int opacity, bool withSlider);
    void sigOpacityFinishedChanging(int previous, int opacity);
    void sigItemComposite(const KisCompositeOp&);

private:
    enum LayerTypes { PAINT_LAYER, GROUP_LAYER, ADJUSTMENT_LAYER, OBJECT_LAYER };

private slots:
    // connect to LayerList signals
    void slotLayerActivated(LayerItem* layer);
    void slotLayerDisplayNameChanged(LayerItem* layer, const TQString& displayName);
    void slotLayerPropertyChanged(LayerItem* layer, const TQString& name, bool on);
    void slotLayerMoved(LayerItem* layer, LayerItem* tqparent, LayerItem* after);
    void slotRequestNewLayer(LayerItem* tqparent, LayerItem* after);
    void slotRequestNewFolder(LayerItem* tqparent, LayerItem* after);
    void slotRequestNewAdjustmentLayer(LayerItem* tqparent, LayerItem* after);
    void slotRequestNewObjectLayer(LayerItem* tqparent, LayerItem* item, const KoDocumentEntry& entry);
    void slotRequestRemoveLayer(LayerItem* layer);
    void slotRequestLayerProperties(LayerItem* layer);

    void slotAboutToShow();
    void slotAddMenuActivated(int type = OBJECT_LAYER);
    void slotRmClicked();
    void slotRaiseClicked();
    void slotLowerClicked();
    void slotPropertiesClicked();

    void updateThumbnails();

private:
    void updateUI();
    TQPixmap loadPixmap(const TQString& filename, const KIconLoader& il, int size);
    KisLayerList* list() const;
    void markModified(KisLayer *layer);

    KPopupMenu *m_newLayerMenu;
    KoPartSelectAction *m_partLayerAction;
    KisImageSP m_image;
    TQValueList<int> m_modified;
    WdgLayerBox *m_lst;

    void printChalkLayers() const;
    void printLayerboxLayers() const;
};

#endif // KIS_LAYERBOX_H