45672722e868d26760d23d028a7c36424141e126
[synfig.git] /
1 /* === S Y N F I G ========================================================= */
2 /*!     \file widget_defaults.cpp
3 **      \brief Template File
4 **
5 **      $Id$
6 **
7 **      \legal
8 **      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **  Copyright (c) 2008 Chris Moore
10 **  Copyright (c) 2008 Carlos López
11 **
12 **      This package is free software; you can redistribute it and/or
13 **      modify it under the terms of the GNU General Public License as
14 **      published by the Free Software Foundation; either version 2 of
15 **      the License, or (at your option) any later version.
16 **
17 **      This package is distributed in the hope that it will be useful,
18 **      but WITHOUT ANY WARRANTY; without even the implied warranty of
19 **      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 **      General Public License for more details.
21 **      \endlegal
22 */
23 /* ========================================================================= */
24
25 /* === H E A D E R S ======================================================= */
26
27 #ifdef USING_PCH
28 #       include "pch.h"
29 #else
30 #ifdef HAVE_CONFIG_H
31 #       include <config.h>
32 #endif
33
34 #include "widget_defaults.h"
35 #include "widget_color.h"
36 #include "widget_gradient.h"
37 #include "dialog_color.h"
38 #include "dialog_gradient.h"
39 #include "app.h"
40 #include <gtkmm/menu.h>
41 #include <gtkmm/scale.h>
42 #include <synfig/exception.h>
43 #include <synfigapp/main.h>
44 #include "canvasview.h"
45 #include "widget_distance.h"
46 #include "widget_enum.h"
47
48 #include "general.h"
49
50 #endif
51
52 /* === U S I N G =========================================================== */
53
54 using namespace std;
55 using namespace etl;
56 using namespace synfig;
57 using namespace studio;
58
59 /* === M A C R O S ========================================================= */
60
61 #define GRADIENT_HEIGHT         16
62 #define DEFAULT_INCREMENT       (0.25)
63 #define DEFAULT_WIDTH           (synfig::Distance(3,synfig::Distance::SYSTEM_POINTS))
64
65 /* === G L O B A L S ======================================================= */
66
67 class studio::Widget_Brush : public Gtk::DrawingArea
68 {
69 public:
70         Widget_Brush()
71         {
72                 signal_expose_event().connect(sigc::mem_fun(*this, &studio::Widget_Brush::redraw));
73
74                 set_size_request(24,24);
75                 add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
76                 add_events(Gdk::BUTTON1_MOTION_MASK);
77
78                 synfigapp::Main::signal_foreground_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Brush::queue_draw));
79                 synfigapp::Main::signal_background_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Brush::queue_draw));
80                 synfigapp::Main::signal_bline_width_changed().connect(sigc::mem_fun(*this,&studio::Widget_Brush::queue_draw));
81                 studio::App::signal_instance_selected().connect(sigc::hide(sigc::mem_fun(*this,&studio::Widget_Brush::queue_draw)));
82         }
83
84         bool
85         redraw(GdkEventExpose */*bleh*/)
86         {
87                 Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
88
89                 const int h(get_height());
90                 const int w(get_width());
91
92                 float pixelsize(0);
93                 if(App::get_selected_canvas_view())
94                 {
95                         const RendDesc& rend_desc(App::get_selected_canvas_view()->get_canvas()->rend_desc());
96                         pixelsize=synfigapp::Main::get_bline_width().get(Distance::SYSTEM_PIXELS,rend_desc);
97                 }
98                 else
99                 {
100                         RendDesc rend_desc;
101                         pixelsize=synfigapp::Main::get_bline_width().get(Distance::SYSTEM_PIXELS,rend_desc);
102                 }
103                 // Fill in the background color
104                 render_color_to_window(get_window(),Gdk::Rectangle(0,0,w,h),synfigapp::Main::get_background_color());
105
106 /*
107                 gc->set_rgb_fg_color(colorconv_synfig2gdk(synfigapp::Main::get_background_color()));
108                 gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
109                 get_window()->draw_rectangle(
110                         gc,
111                         true,   // Fill?
112                         0,0,    // x,y
113                         w,h     //w,h
114                 );
115 */
116
117                 // Draw in the circle
118                 gc->set_rgb_fg_color(colorconv_synfig2gdk(synfigapp::Main::get_foreground_color()));
119                 gc->set_function(Gdk::COPY);
120                 gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
121                 get_window()->draw_arc(
122                         gc,
123                         true,
124                         round_to_int(((float)w/2.0f)-pixelsize/2.0f),
125                         round_to_int(((float)h/2.0f)-pixelsize/2.0f),
126                         round_to_int(pixelsize+0.6),
127                         round_to_int(pixelsize+0.6),
128                         0,
129                         360*64
130                 );
131
132                 return true;
133         }
134
135         bool
136         on_event(GdkEvent *event)
137         {
138 //              const int x(static_cast<int>(event->button.x));
139                 const int y(static_cast<int>(event->button.y));
140
141                 const int h(get_height());
142 //              const int w(get_width());
143
144                 switch(event->type)
145                 {
146                         case GDK_MOTION_NOTIFY:
147                                 break;
148                         case GDK_BUTTON_RELEASE:
149                                 if(event->button.button==1) // Left click
150                                 {
151                                         Distance dist(synfigapp::Main::get_bline_width());
152
153                                         if(y<h/2) // increase BLine size
154                                         {
155                                                 dist+=DEFAULT_INCREMENT;
156                                         }
157                                         else // Decrease BLine size
158                                         {
159                                                 dist-=DEFAULT_INCREMENT;
160                                         }
161                                         synfigapp::Main::set_bline_width(dist);
162                                         return true;
163                                 }
164                                 if(event->button.button==3)
165                                 {
166                                         // right click on bline width
167                                         synfigapp::Main::set_bline_width(DEFAULT_WIDTH);
168                                         return true;
169                                 }
170                                 break;
171                         case GDK_SCROLL:
172                                 {
173                                         Distance dist(synfigapp::Main::get_bline_width());
174
175                                         switch(event->scroll.direction){
176                                                 case GDK_SCROLL_UP:
177                                                 case GDK_SCROLL_RIGHT:
178                                                         dist+=DEFAULT_INCREMENT;
179                                                 break;
180                                                 case GDK_SCROLL_DOWN:
181                                                 case GDK_SCROLL_LEFT:
182                                                         dist-=DEFAULT_INCREMENT;
183                                                 break;
184                                         }
185                                         synfigapp::Main::set_bline_width(dist);
186                                         return true;
187                                 }
188                         default:
189                                 break;
190                 }
191
192                 return false;
193         }
194
195 };
196
197 /* === P R O C E D U R E S ================================================= */
198
199 /* === M E T H O D S ======================================================= */
200
201 Widget_Defaults::Widget_Defaults()
202 {
203         //set_size_request(48,48+GRADIENT_HEIGHT+16);
204         //set_size_request(48,-1);
205
206         {
207                 Gtk::Table* subtable(manage(new Gtk::Table()));
208
209                 // Foreground Color
210                 widget_fg_color=manage(new Widget_Color());
211                 widget_fg_color->show();
212                 widget_fg_color->set_size_request(16,16);
213                 widget_fg_color->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Defaults::on_fg_color_clicked));
214                 subtable->attach(*widget_fg_color, 0, 4, 0, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
215                 tooltips_.set_tip(*widget_fg_color,_("Foreground Color"));
216
217                 // Background Color
218                 widget_bg_color=manage(new Widget_Color());
219                 widget_bg_color->show();
220                 widget_bg_color->set_size_request(16,16);
221                 widget_bg_color->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Defaults::on_bg_color_clicked));
222                 subtable->attach(*widget_bg_color, 3, 7, 3, 7, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
223                 tooltips_.set_tip(*widget_bg_color,_("Background Color"));
224
225                 Gtk::Image* icon;
226
227                 // Swap button
228                 Gtk::Button* button_swap(manage(new Gtk::Button()));
229                 button_swap->show();
230                 button_swap->set_relief(Gtk::RELIEF_NONE);
231                 button_swap->set_border_width(0);
232                 icon=manage(new Gtk::Image(Gtk::StockID("synfig-swap_colors"),Gtk::IconSize(1)));
233                 icon->show();
234                 button_swap->add(*icon);
235                 //button_swap->get_child()->set_size_request(16/3,16/3);
236                 //button_swap->set_size_request(16/3,16/3);
237                 dynamic_cast<Gtk::Misc*>(button_swap->get_child())->set_padding(0,0);
238                 button_swap->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Defaults::on_swap_color_clicked));
239                 subtable->attach(*button_swap, 4, 7, 0, 3, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
240                 tooltips_.set_tip(*button_swap,_("Swap Background and\nForeground Colors"));
241
242                 // Reset button
243                 Gtk::Button* button_reset(manage(new Gtk::Button()));
244                 button_reset->show();
245                 button_reset->set_relief(Gtk::RELIEF_NONE);
246                 button_reset->set_border_width(0);
247                 icon=manage(new Gtk::Image(Gtk::StockID("synfig-reset_colors"),Gtk::IconSize(1)));
248                 icon->show();
249                 button_reset->add(*icon);
250                 dynamic_cast<Gtk::Misc*>(button_reset->get_child())->set_padding(0,0);
251                 //button_reset->set_size_request(16/3,16/3);
252                 button_reset->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Defaults::on_reset_color_clicked));
253                 subtable->attach(*button_reset, 0, 3, 4, 7, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
254                 tooltips_.set_tip(*button_reset,_("Reset Colors to Black and White"));
255
256
257                 attach(*subtable, 0, 1, 0, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 1, 1);
258                 subtable->set_size_request(36,36);
259                 subtable->set_homogeneous(true);
260                 subtable->show();
261         }
262         widget_brush=manage(new Widget_Brush());
263         widget_brush->show();
264         widget_brush->set_size_request(36,36);
265         attach(*widget_brush,1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 1, 1);
266         tooltips_.set_tip(*widget_brush,_("Brush Preview"));
267
268         widget_bline_width=manage(new Widget_Distance());
269         widget_bline_width->show();
270         bline_width_refresh();
271         widget_bline_width->set_digits(2);
272         widget_bline_width->set_range(0,10000000);
273         widget_bline_width->set_size_request(24,-1);
274         widget_bline_width->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::on_bline_width_changed));
275         attach(*widget_bline_width,1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
276         tooltips_.set_tip(*widget_bline_width,_("Brush Size"));
277
278
279         widget_blend_method=manage(new Widget_Enum());
280         widget_blend_method->show();
281         widget_blend_method->signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::on_blend_method_changed));
282         widget_blend_method->set_param_desc(ParamDesc(Color::BLEND_COMPOSITE,"blend_method"));
283         attach(*widget_blend_method,0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 1, 1);
284         tooltips_.set_tip(*widget_blend_method,_("Default Blend Method"));
285
286         widget_interpolation=manage(new Widget_Enum());
287         widget_interpolation->show();
288         widget_interpolation->signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::on_interpolation_changed));
289         widget_interpolation->set_param_desc(
290                 ParamDesc("interpolation")
291                         .set_hint("enum")
292                         .add_enum_value(INTERPOLATION_TCB,"auto",_("_TCB"))
293                         .add_enum_value(INTERPOLATION_CONSTANT,"constant",_("_Constant"))
294                         .add_enum_value(INTERPOLATION_HALT,"ease",_("_Ease In/Out"))
295                         .add_enum_value(INTERPOLATION_LINEAR,"linear",_("_Linear"))
296         );
297         attach(*widget_interpolation,0, 2, 5, 6, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 1, 1);
298         tooltips_.set_tip(*widget_interpolation,_("Default Interpolation"));
299
300         widget_opacity=manage(new Gtk::HScale(0.0f,1.01f,0.01f));
301         widget_opacity->show();
302         widget_opacity->set_digits(2);
303         widget_opacity->set_value_pos(Gtk::POS_LEFT);
304         widget_opacity->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::on_opacity_changed));
305         attach(*widget_opacity,0, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 1, 1);
306         tooltips_.set_tip(*widget_opacity,_("Default Opacity"));
307
308         widget_gradient=manage(new Widget_Gradient());
309         widget_gradient->show();
310         widget_gradient->set_size_request(-1,GRADIENT_HEIGHT);
311         widget_gradient->signal_clicked().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::on_gradient_clicked));
312         attach(*widget_gradient,0, 2, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 1, 1);
313         tooltips_.set_tip(*widget_gradient,_("Default Gradient"));
314
315
316         // Signals
317         synfigapp::Main::signal_opacity_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::opacity_refresh));
318         synfigapp::Main::signal_bline_width_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::bline_width_refresh));
319         synfigapp::Main::signal_foreground_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::fg_color_refresh));
320         synfigapp::Main::signal_background_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::bg_color_refresh));
321         synfigapp::Main::signal_gradient_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::gradient_refresh));
322         synfigapp::Main::signal_blend_method_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::blend_method_refresh));
323         synfigapp::Main::signal_interpolation_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::interpolation_refresh));
324
325         fg_color_refresh();
326         bg_color_refresh();
327         gradient_refresh();
328         blend_method_refresh();
329         opacity_refresh();
330         interpolation_refresh();
331 /*
332         set_size_request(48,48+GRADIENT_HEIGHT);
333         signal_expose_event().connect(sigc::mem_fun(*this, &studio::Widget_Defaults::redraw));
334         add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
335         add_events(Gdk::BUTTON1_MOTION_MASK);
336
337         synfigapp::Main::signal_foreground_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::queue_draw));
338         synfigapp::Main::signal_background_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::queue_draw));
339         synfigapp::Main::signal_gradient_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::queue_draw));
340         synfigapp::Main::signal_bline_width_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::queue_draw));
341
342         if(App::dialog_gradient)
343         {
344                 App::dialog_gradient->set_gradient(synfigapp::Main::get_gradient());
345                 App::dialog_gradient->reset();
346                 App::dialog_gradient->signal_edited().connect(sigc::mem_fun(synfigapp::Main::set_gradient));
347         }
348
349         if(App::dialog_color)
350         {
351                 App::dialog_color->set_color(synfigapp::Main::get_foreground_color());
352                 App::dialog_color->reset();
353                 App::dialog_color->signal_edited().connect(sigc::mem_fun(synfigapp::Main::set_foreground_color));
354         }
355 */
356 }
357
358 Widget_Defaults::~Widget_Defaults()
359 {
360 }
361
362 void
363 Widget_Defaults::fg_color_refresh()
364 {
365         widget_fg_color->set_value(synfigapp::Main::get_foreground_color());
366 }
367
368 void
369 Widget_Defaults::bg_color_refresh()
370 {
371         widget_bg_color->set_value(synfigapp::Main::get_background_color());
372 }
373
374 void
375 Widget_Defaults::gradient_refresh()
376 {
377         widget_gradient->set_value(synfigapp::Main::get_gradient());
378 }
379
380 void
381 Widget_Defaults::bline_width_refresh()
382 {
383         widget_bline_width->set_value(synfigapp::Main::get_bline_width());
384 }
385
386 void
387 Widget_Defaults::blend_method_refresh()
388 {
389         widget_blend_method->set_value(synfigapp::Main::get_blend_method());
390 }
391
392 void
393 Widget_Defaults::interpolation_refresh()
394 {
395         widget_interpolation->set_value(synfigapp::Main::get_interpolation());
396 }
397
398 void
399 Widget_Defaults::opacity_refresh()
400 {
401         widget_opacity->set_value(synfigapp::Main::get_opacity());
402 }
403
404 void
405 Widget_Defaults::on_opacity_changed()
406 {
407         synfigapp::Main::set_opacity(widget_opacity->get_value());
408 }
409
410 void
411 Widget_Defaults::on_blend_method_changed()
412 {
413         synfigapp::Main::set_blend_method(Color::BlendMethod(widget_blend_method->get_value()));
414 }
415
416 void
417 Widget_Defaults::on_interpolation_changed()
418 {
419         synfigapp::Main::set_interpolation(Waypoint::Interpolation(widget_interpolation->get_value()));
420 }
421
422 void
423 Widget_Defaults::on_bline_width_changed()
424 {
425         synfigapp::Main::set_bline_width(widget_bline_width->get_value());
426 }
427
428 void
429 Widget_Defaults::on_fg_color_clicked()
430 {
431         // Left click on foreground
432         App::dialog_color->set_color(synfigapp::Main::get_foreground_color());
433         App::dialog_color->reset();
434         App::dialog_color->signal_edited().connect(sigc::ptr_fun(synfigapp::Main::set_foreground_color));
435         App::dialog_color->present();
436 }
437
438 void
439 Widget_Defaults::on_bg_color_clicked()
440 {
441         // Left click on background
442         App::dialog_color->set_color(synfigapp::Main::get_background_color());
443         App::dialog_color->reset();
444         App::dialog_color->signal_edited().connect(sigc::ptr_fun(synfigapp::Main::set_background_color));
445         App::dialog_color->present();
446 }
447
448 void
449 Widget_Defaults::on_swap_color_clicked()
450 {
451         synfigapp::Main::color_swap();
452 }
453
454 void
455 Widget_Defaults::on_reset_color_clicked()
456 {
457         synfigapp::Main::set_background_color(Color::white());
458         synfigapp::Main::set_foreground_color(Color::black());
459 }
460
461 void
462 Widget_Defaults::on_gradient_clicked()
463 {
464         App::dialog_gradient->set_gradient(synfigapp::Main::get_gradient());
465         App::dialog_gradient->reset();
466         App::dialog_gradient->signal_edited().connect(sigc::ptr_fun(synfigapp::Main::set_gradient));
467         App::dialog_gradient->present();
468 }
469
470 /*
471 bool
472 Widget_Defaults::redraw(GdkEventExpose*bleh)
473 {
474         Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
475
476         const int h(get_height());
477         const int w(get_width());
478         const int size=std::min(h-GRADIENT_HEIGHT,w);
479
480         render_color_to_window(get_window(),Gdk::Rectangle(size/4,size/4,size/4*3-1,size/4*3-1),synfigapp::Main::get_background_color());
481         render_color_to_window(get_window(),Gdk::Rectangle(0,0,size/4*3-1,size/4*3-1),synfigapp::Main::get_foreground_color());
482         render_gradient_to_window(get_window(),Gdk::Rectangle(0,h-GRADIENT_HEIGHT,w,GRADIENT_HEIGHT-1),synfigapp::Main::get_gradient());
483
484
485
486
487
488         Glib::RefPtr<Pango::Layout> layout(Pango::Layout::create(get_pango_context()));
489
490         gc->set_rgb_fg_color(Gdk::Color("#FF0000"));
491         layout->set_text(synfigapp::Main::get_bline_width().get_string(2));
492         layout->set_alignment(Pango::ALIGN_CENTER);
493         layout->set_width(w/2);
494         get_window()->draw_layout(gc, w*3/4, (h-GRADIENT_HEIGHT)-16, layout);
495
496         return true;
497 }
498
499 bool
500 Widget_Defaults::on_event(GdkEvent *event)
501 {
502         const int x(static_cast<int>(event->button.x));
503         const int y(static_cast<int>(event->button.y));
504
505         const int h(get_height());
506         const int w(get_width());
507         const int size=std::min(h-GRADIENT_HEIGHT,w);
508
509         switch(event->type)
510         {
511         case GDK_MOTION_NOTIFY:
512                 break;
513         case GDK_BUTTON_PRESS:
514 //                      if(event->button.button==1 && y>get_height()-CONTROL_HEIGHT)
515                 break;
516         case GDK_BUTTON_RELEASE:
517                 if(event->button.button==1)
518                 {
519                         if(y>size)
520                         {
521                                 // Left click on gradient
522                                 App::dialog_gradient->set_gradient(synfigapp::Main::get_gradient());
523                                 App::dialog_gradient->reset();
524                                 App::dialog_gradient->signal_edited().connect(sigc::mem_fun(synfigapp::Main::set_gradient));
525                                 App::dialog_gradient->present();
526                                 return true;
527                         }
528                         if(x>0 && x<=size)
529                         {
530                                 if(x<size*3/4 && y<size*3/4)
531                                 {
532                                         // Left click on foreground
533                                         App::dialog_color->set_color(synfigapp::Main::get_foreground_color());
534                                         App::dialog_color->reset();
535                                         App::dialog_color->signal_edited().connect(sigc::mem_fun(synfigapp::Main::set_foreground_color));
536                                         App::dialog_color->present();
537                                         return true;
538                                 }
539                                 if(x>size*3/4 && y>size/4)
540                                 {
541                                         // Left click on background
542                                         App::dialog_color->set_color(synfigapp::Main::get_background_color());
543                                         App::dialog_color->reset();
544                                         App::dialog_color->signal_edited().connect(sigc::mem_fun(synfigapp::Main::set_background_color));
545                                         App::dialog_color->present();
546                                         return true;
547                                 }
548                         }
549                         if(x>size) // Left click on BLine Width
550                         {
551                                 Distance dist(synfigapp::Main::get_bline_width());
552
553                                 if(y<size/2) // increase BLine size
554                                 {
555                                         dist+=DEFAULT_INCREMENT;
556                                 }
557                                 else // Decrease BLine size
558                                 {
559                                         dist-=DEFAULT_INCREMENT;
560                                 }
561                                 synfigapp::Main::set_bline_width(dist);
562                         }
563                 }
564                 if(event->button.button==3)
565                 {
566                         if(y>size)
567                         {
568                                 // right click on gradient
569                                 synfigapp::Main::set_gradient_default_colors();
570                                 return true;
571                         }
572                         else
573                         {
574                                 if(x<size)
575                                 {
576                                         // right click on colors
577                                         synfigapp::Main::color_swap();
578                                         return true;
579                                 }
580
581                                 if(x>w/2)
582                                 {
583                                         // right click on bline width
584                                         synfigapp::Main::set_bline_width(DEFAULT_WIDTH);
585                                 }
586
587                         }
588                 }
589                 break;
590         case GDK_SCROLL:
591                 {
592                         Distance dist(synfigapp::Main::get_bline_width());
593
594                         if(event->scroll.direction==GDK_SCROLL_UP)
595                         {
596                                 dist+=DEFAULT_INCREMENT;
597                         }
598                         else if(event->scroll.direction==GDK_SCROLL_DOWN)
599                         {
600                                 dist-=DEFAULT_INCREMENT;
601                         }
602                         synfigapp::Main::set_bline_width(dist);
603                 }
604         default:
605                 break;
606         }
607
608         return false;
609 }
610 */