3 * Copyright (C) 2008-2015 Adam Williams <broadcast at earthling dot net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #ifndef __CRIKEYWINDOW_H__
22 #define __CRIKEYWINDOW_H__
25 #include "colorpicker.h"
29 class SketcherCurveTypeItem;
30 class SketcherCurveType;
31 class SketcherCurvePenItem;
32 class SketcherCurvePen;
33 class SketcherCurveColor;
34 class SketcherCurveColorPicker;
35 class SketcherCurveColorThread;
36 class SketcherNewCurve;
37 class SketcherDelCurve;
38 class SketcherCurveUp;
39 class SketcherCurveDn;
40 class SketcherCurveRadius;
41 class SketcherCurveList;
45 class SketcherPointList;
46 class SketcherNewPoint;
47 class SketcherDelPoint;
48 class SketcherPointUp;
49 class SketcherPointDn;
50 class SketcherResetCurves;
51 class SketcherResetPoints;
54 class SketcherNum : public BC_TumbleTextBox
59 SketcherNum(SketcherWindow *gui, int x, int y, int output,
60 int mn=-32767, int mx=32767);
62 int update(int v) { return BC_TumbleTextBox::update((int64_t)v); }
65 class SketcherCurveTypeItem : public BC_MenuItem
68 SketcherCurveTypeItem(int ty);
73 class SketcherCurveType : public BC_PopupMenu
76 SketcherCurveType(SketcherWindow *gui, int x, int y, int ty);
77 void create_objects();
83 class SketcherCurvePenItem : public BC_MenuItem
86 SketcherCurvePenItem(int pen);
91 class SketcherCurvePen : public BC_PopupMenu
94 SketcherCurvePen(SketcherWindow *gui, int x, int y, int pen);
95 void create_objects();
101 class SketcherCurveColor : public BC_Button
104 SketcherCurveColor(SketcherWindow *gui, int x, int y, int w);
105 ~SketcherCurveColor();
107 void set_color(int color);
108 void update_gui(int color);
116 class SketcherCurveColorPicker : public ColorPicker
119 SketcherCurveColorPicker(SketcherWindow *gui, SketcherCurveColor *curve_color);
120 ~SketcherCurveColorPicker();
121 void start(int color);
122 int handle_new_color(int color, int alpha);
124 void handle_done_event(int result);
128 SketcherCurveColor *color_button;
129 SketcherCurveColorThread *color_update;
132 class SketcherCurveColorThread : public Thread
135 SketcherCurveColorThread(SketcherCurveColorPicker *color_picker);
136 ~SketcherCurveColorThread();
142 SketcherCurveColorPicker *color_picker;
144 Condition *update_lock;
147 class SketcherNewCurve : public BC_GenericButton
150 SketcherNewCurve(SketcherWindow *gui, Sketcher *plugin, int x, int y);
159 class SketcherDelCurve : public BC_GenericButton
162 SketcherDelCurve(SketcherWindow *gui, Sketcher *plugin, int x, int y);
171 class SketcherCurveUp : public BC_GenericButton
174 SketcherCurveUp(SketcherWindow *gui, int x, int y);
182 class SketcherCurveDn : public BC_GenericButton
185 SketcherCurveDn(SketcherWindow *gui, int x, int y);
193 class SketcherCurveRadius : public SketcherNum
196 SketcherCurveRadius(SketcherWindow *gui, int x, int y, float output)
197 : SketcherNum(gui, x, y, output, 0, 255) {}
198 ~SketcherCurveRadius() {}
203 class SketcherCurveList : public BC_ListBox
206 SketcherCurveList(SketcherWindow *gui, Sketcher *plugin, int x, int y);
207 ~SketcherCurveList();
210 int selection_changed();
211 int column_resize_event();
212 ArrayList<BC_ListBoxItem*> cols[CV_SZ];
214 void add_curve(const char *id, const char *type,
215 const char *radius, const char *pen, const char *color);
216 void del_curve(int i);
217 void set_selected(int k);
219 void update_list(int k);
223 const char *titles[CV_SZ];
228 class SketcherPointX : public SketcherNum
231 SketcherPointX(SketcherWindow *gui, int x, int y, float output)
232 : SketcherNum(gui, x, y, output) {}
237 class SketcherPointY : public SketcherNum
240 SketcherPointY(SketcherWindow *gui, int x, int y, float output)
241 : SketcherNum(gui, x, y, output) {}
248 class SketcherDrag : public BC_CheckBox
251 SketcherDrag(SketcherWindow *gui, int x, int y);
258 class SketcherPointList : public BC_ListBox
261 SketcherPointList(SketcherWindow *gui, Sketcher *plugin, int x, int y);
262 ~SketcherPointList();
265 int selection_changed();
266 int column_resize_event();
267 ArrayList<BC_ListBoxItem*> cols[PT_SZ];
269 void add_point(const char *id, const char *xp, const char *yp);
270 void set_point(int i, int c, int v);
271 void set_point(int i, int c, const char *cp);
272 void set_selected(int k);
274 void update_list(int k);
279 const char *titles[PT_SZ];
283 class SketcherNewPoint : public BC_GenericButton
286 SketcherNewPoint(SketcherWindow *gui, Sketcher *plugin, int x, int y);
295 class SketcherDelPoint : public BC_GenericButton
298 SketcherDelPoint(SketcherWindow *gui, Sketcher *plugin, int x, int y);
307 class SketcherPointUp : public BC_GenericButton
310 SketcherPointUp(SketcherWindow *gui, int x, int y);
318 class SketcherPointDn : public BC_GenericButton
321 SketcherPointDn(SketcherWindow *gui, int x, int y);
329 class SketcherResetCurves : public BC_GenericButton
332 SketcherResetCurves(SketcherWindow *gui, Sketcher *plugin, int x, int y);
333 ~SketcherResetCurves();
341 class SketcherResetPoints : public BC_GenericButton
344 SketcherResetPoints(SketcherWindow *gui, Sketcher *plugin, int x, int y);
345 ~SketcherResetPoints();
354 class SketcherWindow : public PluginClientWindow
357 SketcherWindow(Sketcher *plugin);
360 void create_objects();
362 void start_color_thread(SketcherCurveColor *curve_color);
363 int grab_event(XEvent *event);
364 int do_grab_event(XEvent *event);
365 void done_event(int result);
366 void send_configure_change();
367 int keypress_event();
371 BC_Title *title_type, *title_pen;
372 BC_Title *title_color, *title_radius;
373 SketcherCurveType *curve_type;
374 SketcherCurvePen *curve_pen;
375 SketcherCurveColor *curve_color;
376 SketcherCurveColorPicker *color_picker;
377 SketcherNewCurve *new_curve;
378 SketcherDelCurve *del_curve;
379 SketcherCurveUp *curve_up;
380 SketcherCurveDn *curve_dn;
381 SketcherCurveRadius *curve_radius;
382 SketcherCurveList *curve_list;
383 SketcherResetCurves *reset_curves;
385 BC_Title *title_x, *title_y;
386 SketcherPointX *point_x;
387 SketcherPointY *point_y;
388 SketcherNewPoint *new_point;
389 SketcherDelPoint *del_point;
390 SketcherPointUp *point_up;
391 SketcherPointDn *point_dn;
392 int dragging, pending_config;
394 float last_x, last_y;
396 SketcherPointList *point_list;
397 SketcherResetPoints *reset_points;
398 BC_Title *notes0, *notes1, *notes2;