Add "By Layer Default" blend method to the Toolbox Defaults widget.
[synfig.git] / synfig-studio / src / gui / widgets / 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 "widgets/widget_defaults.h"
35 #include "widgets/widget_color.h"
36 #include "widgets/widget_gradient.h"
37 #include "dialogs/dialog_color.h"
38 #include "dialogs/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 "widgets/widget_distance.h"
46 #include "widgets/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(
283                 ParamDesc(Color::BLEND_COMPOSITE,"blend_method")
284                 .add_enum_value(Color::BLEND_BY_LAYER,"bylayer", _("By Layer Default"))
285         );
286         attach(*widget_blend_method,0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 1, 1);
287         tooltips_.set_tip(*widget_blend_method,_("Default Blend Method"));
288
289         widget_interpolation=manage(new Widget_Enum());
290         widget_interpolation->show();
291         widget_interpolation->signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::on_interpolation_changed));
292         widget_interpolation->set_param_desc(
293                 ParamDesc("interpolation")
294                         .set_hint("enum")
295                         .add_enum_value(INTERPOLATION_TCB,"auto",_("_TCB"))
296                         .add_enum_value(INTERPOLATION_CONSTANT,"constant",_("_Constant"))
297                         .add_enum_value(INTERPOLATION_HALT,"ease",_("_Ease In/Out"))
298                         .add_enum_value(INTERPOLATION_LINEAR,"linear",_("_Linear"))
299         );
300         attach(*widget_interpolation,0, 2, 5, 6, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 1, 1);
301         tooltips_.set_tip(*widget_interpolation,_("Default Interpolation"));
302
303         widget_opacity=manage(new Gtk::HScale(0.0f,1.01f,0.01f));
304         widget_opacity->show();
305         widget_opacity->set_digits(2);
306         widget_opacity->set_value_pos(Gtk::POS_LEFT);
307         widget_opacity->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::on_opacity_changed));
308         attach(*widget_opacity,0, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 1, 1);
309         tooltips_.set_tip(*widget_opacity,_("Default Opacity"));
310
311         widget_gradient=manage(new Widget_Gradient());
312         widget_gradient->show();
313         widget_gradient->set_size_request(-1,GRADIENT_HEIGHT);
314         widget_gradient->signal_clicked().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::on_gradient_clicked));
315         attach(*widget_gradient,0, 2, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 1, 1);
316         tooltips_.set_tip(*widget_gradient,_("Default Gradient"));
317
318
319         // Signals
320         synfigapp::Main::signal_opacity_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::opacity_refresh));
321         synfigapp::Main::signal_bline_width_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::bline_width_refresh));
322         synfigapp::Main::signal_outline_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::otln_color_refresh));
323         synfigapp::Main::signal_fill_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::fill_color_refresh));
324         synfigapp::Main::signal_gradient_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::gradient_refresh));
325         synfigapp::Main::signal_blend_method_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::blend_method_refresh));
326         synfigapp::Main::signal_interpolation_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::interpolation_refresh));
327
328         otln_color_refresh();
329         fill_color_refresh();
330         gradient_refresh();
331         blend_method_refresh();
332         opacity_refresh();
333         interpolation_refresh();
334 /*
335         set_size_request(48,48+GRADIENT_HEIGHT);
336         signal_expose_event().connect(sigc::mem_fun(*this, &studio::Widget_Defaults::redraw));
337         add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
338         add_events(Gdk::BUTTON1_MOTION_MASK);
339
340         synfigapp::Main::signal_outline_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::queue_draw));
341         synfigapp::Main::signal_fill_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::queue_draw));
342         synfigapp::Main::signal_gradient_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::queue_draw));
343         synfigapp::Main::signal_bline_width_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::queue_draw));
344
345         if(App::dialog_gradient)
346         {
347                 App::dialog_gradient->set_gradient(synfigapp::Main::get_gradient());
348                 App::dialog_gradient->reset();
349                 App::dialog_gradient->signal_edited().connect(sigc::mem_fun(synfigapp::Main::set_gradient));
350         }
351
352         if(App::dialog_color)
353         {
354                 App::dialog_color->set_color(synfigapp::Main::get_outline_color());
355                 App::dialog_color->reset();
356                 App::dialog_color->signal_edited().connect(sigc::mem_fun(synfigapp::Main::set_outline_color));
357         }
358 */
359 }
360
361 Widget_Defaults::~Widget_Defaults()
362 {
363 }
364
365 void
366 Widget_Defaults::otln_color_refresh()
367 {
368         widget_otln_color->set_value(synfigapp::Main::get_outline_color());
369 }
370
371 void
372 Widget_Defaults::fill_color_refresh()
373 {
374         widget_fill_color->set_value(synfigapp::Main::get_fill_color());
375 }
376
377 void
378 Widget_Defaults::gradient_refresh()
379 {
380         widget_gradient->set_value(synfigapp::Main::get_gradient());
381 }
382
383 void
384 Widget_Defaults::bline_width_refresh()
385 {
386         widget_bline_width->set_value(synfigapp::Main::get_bline_width());
387 }
388
389 void
390 Widget_Defaults::blend_method_refresh()
391 {
392         widget_blend_method->set_value(synfigapp::Main::get_blend_method());
393 }
394
395 void
396 Widget_Defaults::interpolation_refresh()
397 {
398         widget_interpolation->set_value(synfigapp::Main::get_interpolation());
399 }
400
401 void
402 Widget_Defaults::opacity_refresh()
403 {
404         widget_opacity->set_value(synfigapp::Main::get_opacity());
405 }
406
407 void
408 Widget_Defaults::on_opacity_changed()
409 {
410         synfigapp::Main::set_opacity(widget_opacity->get_value());
411 }
412
413 void
414 Widget_Defaults::on_blend_method_changed()
415 {
416         synfigapp::Main::set_blend_method(Color::BlendMethod(widget_blend_method->get_value()));
417 }
418
419 void
420 Widget_Defaults::on_interpolation_changed()
421 {
422         synfigapp::Main::set_interpolation(Waypoint::Interpolation(widget_interpolation->get_value()));
423 }
424
425 void
426 Widget_Defaults::on_bline_width_changed()
427 {
428         synfigapp::Main::set_bline_width(widget_bline_width->get_value());
429 }
430
431 void
432 Widget_Defaults::on_otln_color_clicked()
433 {
434         // Left click on outline color
435         App::dialog_color->set_color(synfigapp::Main::get_outline_color());
436         App::dialog_color->reset();
437         App::dialog_color->signal_edited().connect(sigc::ptr_fun(synfigapp::Main::set_outline_color));
438         App::dialog_color->present();
439 }
440
441 void
442 Widget_Defaults::on_fill_color_clicked()
443 {
444         // Left click on fill color
445         App::dialog_color->set_color(synfigapp::Main::get_fill_color());
446         App::dialog_color->reset();
447         App::dialog_color->signal_edited().connect(sigc::ptr_fun(synfigapp::Main::set_fill_color));
448         App::dialog_color->present();
449 }
450
451 void
452 Widget_Defaults::on_swap_color_clicked()
453 {
454         synfigapp::Main::color_swap();
455 }
456
457 void
458 Widget_Defaults::on_reset_color_clicked()
459 {
460         synfigapp::Main::set_fill_color(Color::white());
461         synfigapp::Main::set_outline_color(Color::black());
462 }
463
464 void
465 Widget_Defaults::on_gradient_clicked()
466 {
467         App::dialog_gradient->set_gradient(synfigapp::Main::get_gradient());
468         App::dialog_gradient->reset();
469         App::dialog_gradient->signal_edited().connect(sigc::ptr_fun(synfigapp::Main::set_gradient));
470         App::dialog_gradient->set_default_button_set_sensitive(false);
471         App::dialog_gradient->present();
472 }
473
474 /*
475 bool
476 Widget_Defaults::redraw(GdkEventExpose*bleh)
477 {
478         Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
479
480         const int h(get_height());
481         const int w(get_width());
482         const int size=std::min(h-GRADIENT_HEIGHT,w);
483
484         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());
485         render_color_to_window(get_window(),Gdk::Rectangle(0,0,size/4*3-1,size/4*3-1),synfigapp::Main::get_outline_color());
486         render_gradient_to_window(get_window(),Gdk::Rectangle(0,h-GRADIENT_HEIGHT,w,GRADIENT_HEIGHT-1),synfigapp::Main::get_gradient());
487
488
489
490
491
492         Glib::RefPtr<Pango::Layout> layout(Pango::Layout::create(get_pango_context()));
493
494         gc->set_rgb_fg_color(Gdk::Color("#FF0000"));
495         layout->set_text(synfigapp::Main::get_bline_width().get_string(2));
496         layout->set_alignment(Pango::ALIGN_CENTER);
497         layout->set_width(w/2);
498         get_window()->draw_layout(gc, w*3/4, (h-GRADIENT_HEIGHT)-16, layout);
499
500         return true;
501 }
502
503 bool
504 Widget_Defaults::on_event(GdkEvent *event)
505 {
506         const int x(static_cast<int>(event->button.x));
507         const int y(static_cast<int>(event->button.y));
508
509         const int h(get_height());
510         const int w(get_width());
511         const int size=std::min(h-GRADIENT_HEIGHT,w);
512
513         switch(event->type)
514         {
515         case GDK_MOTION_NOTIFY:
516                 break;
517         case GDK_BUTTON_PRESS:
518 //                      if(event->button.button==1 && y>get_height()-CONTROL_HEIGHT)
519                 break;
520         case GDK_BUTTON_RELEASE:
521                 if(event->button.button==1)
522                 {
523                         if(y>size)
524                         {
525                                 // Left click on gradient
526                                 App::dialog_gradient->set_gradient(synfigapp::Main::get_gradient());
527                                 App::dialog_gradient->reset();
528                                 App::dialog_gradient->signal_edited().connect(sigc::mem_fun(synfigapp::Main::set_gradient));
529                                 App::dialog_gradient->present();
530                                 return true;
531                         }
532                         if(x>0 && x<=size)
533                         {
534                                 if(x<size*3/4 && y<size*3/4)
535                                 {
536                                         // Left click on outline coloe
537                                         App::dialog_color->set_color(synfigapp::Main::get_outline_color());
538                                         App::dialog_color->reset();
539                                         App::dialog_color->signal_edited().connect(sigc::mem_fun(synfigapp::Main::set_outline_color));
540                                         App::dialog_color->present();
541                                         return true;
542                                 }
543                                 if(x>size*3/4 && y>size/4)
544                                 {
545                                         // Left click on fill color
546                                         App::dialog_color->set_color(synfigapp::Main::get_fill_color());
547                                         App::dialog_color->reset();
548                                         App::dialog_color->signal_edited().connect(sigc::mem_fun(synfigapp::Main::set_fill_color));
549                                         App::dialog_color->present();
550                                         return true;
551                                 }
552                         }
553                         if(x>size) // Left click on BLine Width
554                         {
555                                 Distance dist(synfigapp::Main::get_bline_width());
556
557                                 if(y<size/2) // increase BLine size
558                                 {
559                                         dist+=DEFAULT_INCREMENT;
560                                 }
561                                 else // Decrease BLine size
562                                 {
563                                         dist-=DEFAULT_INCREMENT;
564                                 }
565                                 synfigapp::Main::set_bline_width(dist);
566                         }
567                 }
568                 if(event->button.button==3)
569                 {
570                         if(y>size)
571                         {
572                                 // right click on gradient
573                                 synfigapp::Main::set_gradient_default_colors();
574                                 return true;
575                         }
576                         else
577                         {
578                                 if(x<size)
579                                 {
580                                         // right click on colors
581                                         synfigapp::Main::color_swap();
582                                         return true;
583                                 }
584
585                                 if(x>w/2)
586                                 {
587                                         // right click on bline width
588                                         synfigapp::Main::set_bline_width(DEFAULT_WIDTH);
589                                 }
590
591                         }
592                 }
593                 break;
594         case GDK_SCROLL:
595                 {
596                         Distance dist(synfigapp::Main::get_bline_width());
597
598                         if(event->scroll.direction==GDK_SCROLL_UP)
599                         {
600                                 dist+=DEFAULT_INCREMENT;
601                         }
602                         else if(event->scroll.direction==GDK_SCROLL_DOWN)
603                         {
604                                 dist-=DEFAULT_INCREMENT;
605                         }
606                         synfigapp::Main::set_bline_width(dist);
607                 }
608         default:
609                 break;
610         }
611
612         return false;
613 }
614 */