e672b8f63a7cd70b318b3944f79cf8aaa9c899aa
[synfig.git] / widget_defaults.cpp
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_outline_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Brush::queue_draw));
79                 synfigapp::Main::signal_fill_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 fill color
104                 render_color_to_window(get_window(),Gdk::Rectangle(0,0,w,h),synfigapp::Main::get_fill_color());
105
106 /*
107                 gc->set_rgb_fg_color(colorconv_synfig2gdk(synfigapp::Main::get_fill_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_outline_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                 // Outline Color
210                 widget_otln_color=manage(new Widget_Color());
211                 widget_otln_color->show();
212                 widget_otln_color->set_size_request(16,16);
213                 widget_otln_color->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Defaults::on_otln_color_clicked));
214                 subtable->attach(*widget_otln_color, 0, 4, 0, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
215                 tooltips_.set_tip(*widget_otln_color,_("Outline Color"));
216
217                 // Fill Color
218                 widget_fill_color=manage(new Widget_Color());
219                 widget_fill_color->show();
220                 widget_fill_color->set_size_request(16,16);
221                 widget_fill_color->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Defaults::on_fill_color_clicked));
222                 subtable->attach(*widget_fill_color, 3, 7, 3, 7, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
223                 tooltips_.set_tip(*widget_fill_color,_("Fill 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 Fill and\nOutline 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_outline_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::otln_color_refresh));
320         synfigapp::Main::signal_fill_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::fill_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         otln_color_refresh();
326         fill_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_outline_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::queue_draw));
338         synfigapp::Main::signal_fill_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_outline_color());
352                 App::dialog_color->reset();
353                 App::dialog_color->signal_edited().connect(sigc::mem_fun(synfigapp::Main::set_outline_color));
354         }
355 */
356 }
357
358 Widget_Defaults::~Widget_Defaults()
359 {
360 }
361
362 void
363 Widget_Defaults::otln_color_refresh()
364 {
365         widget_otln_color->set_value(synfigapp::Main::get_outline_color());
366 }
367
368 void
369 Widget_Defaults::fill_color_refresh()
370 {
371         widget_fill_color->set_value(synfigapp::Main::get_fill_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_otln_color_clicked()
430 {
431         // Left click on outline color
432         App::dialog_color->set_color(synfigapp::Main::get_outline_color());
433         App::dialog_color->reset();
434         App::dialog_color->signal_edited().connect(sigc::ptr_fun(synfigapp::Main::set_outline_color));
435         App::dialog_color->present();
436 }
437
438 void
439 Widget_Defaults::on_fill_color_clicked()
440 {
441         // Left click on fill color
442         App::dialog_color->set_color(synfigapp::Main::get_fill_color());
443         App::dialog_color->reset();
444         App::dialog_color->signal_edited().connect(sigc::ptr_fun(synfigapp::Main::set_fill_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_fill_color(Color::white());
458         synfigapp::Main::set_outline_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->grab_button_set_sensitive(false);
468         App::dialog_gradient->present();
469 }
470
471 /*
472 bool
473 Widget_Defaults::redraw(GdkEventExpose*bleh)
474 {
475         Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
476
477         const int h(get_height());
478         const int w(get_width());
479         const int size=std::min(h-GRADIENT_HEIGHT,w);
480
481         render_color_to_window(get_window(),Gdk::Rectangle(size/4,size/4,size/4*3-1,size/4*3-1),synfigapp::Main::get_fill_color());
482         render_color_to_window(get_window(),Gdk::Rectangle(0,0,size/4*3-1,size/4*3-1),synfigapp::Main::get_outline_color());
483         render_gradient_to_window(get_window(),Gdk::Rectangle(0,h-GRADIENT_HEIGHT,w,GRADIENT_HEIGHT-1),synfigapp::Main::get_gradient());
484
485
486
487
488
489         Glib::RefPtr<Pango::Layout> layout(Pango::Layout::create(get_pango_context()));
490
491         gc->set_rgb_fg_color(Gdk::Color("#FF0000"));
492         layout->set_text(synfigapp::Main::get_bline_width().get_string(2));
493         layout->set_alignment(Pango::ALIGN_CENTER);
494         layout->set_width(w/2);
495         get_window()->draw_layout(gc, w*3/4, (h-GRADIENT_HEIGHT)-16, layout);
496
497         return true;
498 }
499
500 bool
501 Widget_Defaults::on_event(GdkEvent *event)
502 {
503         const int x(static_cast<int>(event->button.x));
504         const int y(static_cast<int>(event->button.y));
505
506         const int h(get_height());
507         const int w(get_width());
508         const int size=std::min(h-GRADIENT_HEIGHT,w);
509
510         switch(event->type)
511         {
512         case GDK_MOTION_NOTIFY:
513                 break;
514         case GDK_BUTTON_PRESS:
515 //                      if(event->button.button==1 && y>get_height()-CONTROL_HEIGHT)
516                 break;
517         case GDK_BUTTON_RELEASE:
518                 if(event->button.button==1)
519                 {
520                         if(y>size)
521                         {
522                                 // Left click on gradient
523                                 App::dialog_gradient->set_gradient(synfigapp::Main::get_gradient());
524                                 App::dialog_gradient->reset();
525                                 App::dialog_gradient->signal_edited().connect(sigc::mem_fun(synfigapp::Main::set_gradient));
526                                 App::dialog_gradient->present();
527                                 return true;
528                         }
529                         if(x>0 && x<=size)
530                         {
531                                 if(x<size*3/4 && y<size*3/4)
532                                 {
533                                         // Left click on outline coloe
534                                         App::dialog_color->set_color(synfigapp::Main::get_outline_color());
535                                         App::dialog_color->reset();
536                                         App::dialog_color->signal_edited().connect(sigc::mem_fun(synfigapp::Main::set_outline_color));
537                                         App::dialog_color->present();
538                                         return true;
539                                 }
540                                 if(x>size*3/4 && y>size/4)
541                                 {
542                                         // Left click on fill color
543                                         App::dialog_color->set_color(synfigapp::Main::get_fill_color());
544                                         App::dialog_color->reset();
545                                         App::dialog_color->signal_edited().connect(sigc::mem_fun(synfigapp::Main::set_fill_color));
546                                         App::dialog_color->present();
547                                         return true;
548                                 }
549                         }
550                         if(x>size) // Left click on BLine Width
551                         {
552                                 Distance dist(synfigapp::Main::get_bline_width());
553
554                                 if(y<size/2) // increase BLine size
555                                 {
556                                         dist+=DEFAULT_INCREMENT;
557                                 }
558                                 else // Decrease BLine size
559                                 {
560                                         dist-=DEFAULT_INCREMENT;
561                                 }
562                                 synfigapp::Main::set_bline_width(dist);
563                         }
564                 }
565                 if(event->button.button==3)
566                 {
567                         if(y>size)
568                         {
569                                 // right click on gradient
570                                 synfigapp::Main::set_gradient_default_colors();
571                                 return true;
572                         }
573                         else
574                         {
575                                 if(x<size)
576                                 {
577                                         // right click on colors
578                                         synfigapp::Main::color_swap();
579                                         return true;
580                                 }
581
582                                 if(x>w/2)
583                                 {
584                                         // right click on bline width
585                                         synfigapp::Main::set_bline_width(DEFAULT_WIDTH);
586                                 }
587
588                         }
589                 }
590                 break;
591         case GDK_SCROLL:
592                 {
593                         Distance dist(synfigapp::Main::get_bline_width());
594
595                         if(event->scroll.direction==GDK_SCROLL_UP)
596                         {
597                                 dist+=DEFAULT_INCREMENT;
598                         }
599                         else if(event->scroll.direction==GDK_SCROLL_DOWN)
600                         {
601                                 dist-=DEFAULT_INCREMENT;
602                         }
603                         synfigapp::Main::set_bline_width(dist);
604                 }
605         default:
606                 break;
607         }
608
609         return false;
610 }
611 */