chalk

kis_filters_listview.h
1/*
2 * This file is part of Chalk
3 *
4 * Copyright (c) 2005 Cyrille Berger <cberger@cberger.net>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 */
21#ifndef _KIS_FILTERS_LIST_VIEW_H_
22#define _KIS_FILTERS_LIST_VIEW_H_
23
24#include <tqevent.h>
25
26#include <kiconview.h>
27
28#include "kis_id.h"
29#include "kis_types.h"
30#include "kis_layer.h"
31#include "kis_paint_device.h"
32#include "kis_thread.h"
33
34class KisView;
35class KisFilter;
37class KisPreviewView;
38class KisFiltersIconViewItem;
39class KisFiltersListView;
40class KisThreadPool;
41
42class KisThumbnailDoneEvent : public TQCustomEvent
43{
44public:
45
46 KisThumbnailDoneEvent(KisFiltersIconViewItem * iconItem, const TQImage & img)
47 : TQCustomEvent(TQEvent::User + 1969)
48 , m_iconItem(iconItem)
49 , m_image(img) {};
50
51 KisFiltersIconViewItem * m_iconItem;
52 TQImage m_image;
53
54};
55
56
57class KisFiltersThumbnailThread : public KisThread
58{
59public:
60
61 KisFiltersThumbnailThread(TQIconView * parent,
62 KisFiltersIconViewItem * iconItem,
63 KisFilterConfiguration * config, KisFilter * filter,
64 KisPaintDeviceSP dev, const TQRect & bounds,
65 KisProfile * profile);
66
67 ~KisFiltersThumbnailThread();
68
69 virtual void run();
70 TQPixmap pixmap();
71 void cancel();
72
73private:
74 TQIconView * m_parent;
75 KisFiltersIconViewItem * m_iconItem;
76 KisFilterConfiguration * m_config;
77 KisFilter * m_filter;
78 KisPaintDeviceSP m_dev;
79 const TQRect m_bounds;
80 KisProfile * m_profile;
81 TQImage m_pixmap;
82};
83
84class KisFiltersIconViewItem : public TQIconViewItem {
85public:
86 KisFiltersIconViewItem( TQIconView * parent, const TQString & text, const TQPixmap & icon,
87 KisID id, KisFilter* filter, KisFilterConfiguration* filterConfig,
88 KisPaintDeviceSP thumb, const TQRect & bounds, KisProfile * profile);
89
90 virtual ~KisFiltersIconViewItem();
91 KisID id() { return m_id; }
92 KisFilter* filter() { return m_filter; }
93 void setFilterConfiguration(KisFilterConfiguration* fc) { m_filterconfig = fc; }
94
95 void resetThread() { m_thread = 0; };
96 KisThread * thread() { return m_thread; }
97
98private:
99 KisID m_id;
100 KisFilter* m_filter;
101 KisFilterConfiguration* m_filterconfig;
102 KisFiltersThumbnailThread * m_thread;
103};
104
105class KisFiltersListView : public TDEIconView {
106
107public:
108 explicit KisFiltersListView(TQWidget * parent = 0, const char * name = 0, WFlags f = 0, bool filterForAdjustmentLayers = false);
109 KisFiltersListView(TQWidget* parent, bool filterForAdjustmentLayers = false, const char* name = 0);
110 KisFiltersListView(KisLayerSP layer, TQWidget* parent, bool filterForAdjustmentLayers = false, const char * name = 0) TDE_DEPRECATED;
111 KisFiltersListView(KisPaintDeviceSP layer, TQWidget* parent, bool filterForAdjustmentLayers = false, const char * name = 0);
112
113 virtual void customEvent(TQCustomEvent *);
114
115 private:
116
117 void init();
118
119public:
120 void setLayer(KisLayerSP layer) TDE_DEPRECATED;
121 void setProfile(KisProfile * profile) { m_profile = profile; };
122
123 inline void setPaintDevice(KisPaintDeviceSP pd) {
124 if( pd != m_original)
125 {
126 m_original = pd;
127 buildPreview();
128 }
129 }
130 void buildPreview();
131 void setCurrentFilter(KisID filter);
132
133private:
134
135 KisPaintDeviceSP m_original;
136 KisImageSP m_imgthumb;
137 KisPaintDeviceSP m_thumb;
138 KisProfile * m_profile;
139 KisThreadPool * threadPool;
140 bool m_filterForAdjustmentLayers;
141};
142
143#endif
A KisFilterConfiguration is the serializable representation of the filter parameters.
Basic interface of a Chalk filter.
Definition kis_filter.h:46
Chalk has a large number of extensible resources.
Definition kis_id.h:57
A thread pool starts executing threads some time after they are added, running a maximum number of th...
A KisThread is a TQThread that can be set in the canceled state.
Definition kis_thread.h:30
virtual void cancel()
Request the thread to cancel at the first opportunity.
Definition kis_thread.h:45