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