1 /* === S Y N F I G ========================================================= */
3 ** \brief Template Header
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 ** Copyright (c) 2006 Yue Shi Lai
10 ** Copyright (c) 2007, 2008 Chris Moore
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.
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.
23 /* ========================================================================= */
25 /* === H E A D E R S ======================================================= */
34 #include <sigc++/adaptors/hide.h>
37 #include "canvasview.h"
39 #include <gtkmm/window.h>
40 #include <gtkmm/image.h>
41 #include <gtkmm/drawingarea.h>
42 #include <gtkmm/ruler.h>
43 #include <gtkmm/arrow.h>
44 #include <gtkmm/image.h>
45 #include <gtkmm/scrollbar.h>
47 #include <sigc++/retype_return.h>
48 #include <sigc++/retype.h>
49 #include <sigc++/hide.h>
52 #include <synfig/target_scanline.h>
53 #include <synfig/target_tile.h>
54 #include <synfig/surface.h>
55 #include <synfig/valuenode_composite.h>
56 #include <synfigapp/canvasinterface.h>
57 #include "event_mouse.h"
58 #include "event_layerclick.h"
59 #include "widget_color.h"
60 #include <synfig/distance.h>
61 #include "workarearenderer.h"
63 #include "renderer_canvas.h"
64 #include "renderer_grid.h"
65 #include "renderer_guides.h"
66 #include "renderer_timecode.h"
67 #include "renderer_ducks.h"
68 #include "renderer_dragbox.h"
69 #include "renderer_bbox.h"
70 #include "asyncrenderer.h"
71 #include <gtkmm/frame.h>
73 #include <synfig/mutex.h>
79 /* === U S I N G =========================================================== */
83 using namespace synfig;
84 using namespace studio;
86 /* === M A C R O S ========================================================= */
89 #define stratof(X) (atof((X).c_str()))
90 #define stratoi(X) (atoi((X).c_str()))
94 /* === G L O B A L S ======================================================= */
96 /* === C L A S S E S ======================================================= */
98 class studio::WorkAreaTarget : public synfig::Target_Tile
104 int real_tile_w,real_tile_h;
105 //std::vector<Glib::RefPtr<Gdk::Pixbuf> >::iterator tile_iter;
107 int twindow_start, twindow_width, twindow_height, twindow_pad;
111 bool onion_first_tile;
114 std::list<synfig::Time> onion_skin_queue;
118 void set_onion_skin(bool x, int *onions)
122 Time time(rend_desc().get_time_start());
126 onion_skin_queue.push_back(time);
131 for(int i=0; i<onions[0]; i++)
133 Time keytime=get_canvas()->keyframe_list().find_prev(thistime)->get_time();
134 onion_skin_queue.push_back(keytime);
144 for(int i=0; i<onions[1]; i++)
146 Time keytime=get_canvas()->keyframe_list().find_next(thistime)->get_time();
147 onion_skin_queue.push_back(keytime);
154 onion_layers=onion_skin_queue.size();
156 onion_first_tile=false;
160 WorkAreaTarget(WorkArea *workarea,int w, int h):
162 low_res(workarea->get_low_resolution_flag()),
165 real_tile_w(workarea->tile_w),
166 real_tile_h(workarea->tile_h),
167 refresh_id(workarea->refreshes),
171 //set_remove_alpha();
172 //set_avoid_time_sync();
176 int div = workarea->get_low_res_pixel_size();
177 set_tile_w(workarea->tile_w/div);
178 set_tile_h(workarea->tile_h/div);
182 set_tile_w(workarea->tile_w);
183 set_tile_h(workarea->tile_h);
185 set_canvas(workarea->get_canvas());
186 set_quality(workarea->get_quality());
191 workarea->queue_draw();
194 virtual bool set_rend_desc(synfig::RendDesc *newdesc)
197 newdesc->set_flags(RendDesc::PX_ASPECT|RendDesc::IM_SPAN);
199 int div = workarea->get_low_res_pixel_size();
200 newdesc->set_wh(w/div,h/div);
203 newdesc->set_wh(w,h);
207 || workarea->get_h()!=h
208 ) workarea->set_wh(w,h,4);
210 workarea->full_frame=false;
216 virtual int total_tiles()const
218 int tw(rend_desc().get_w()/get_tile_w());
219 int th(rend_desc().get_h()/get_tile_h());
220 if(rend_desc().get_w()%get_tile_w()!=0)tw++;
221 if(rend_desc().get_h()%get_tile_h()!=0)th++;
225 virtual int next_frame(Time& time)
227 synfig::Mutex::Lock lock(mutex);
230 return synfig::Target_Tile::next_frame(time);
232 onion_first_tile=(onion_layers==(signed)onion_skin_queue.size());
234 if(!onion_skin_queue.empty())
236 time=onion_skin_queue.front();
237 onion_skin_queue.pop_front();
242 return onion_skin_queue.size()+1;
245 virtual int next_tile(int& x, int& y)
247 synfig::Mutex::Lock lock(mutex);
248 //if(workarea->tile_queue.empty()) return 0;
250 //int curr_tile(workarea->tile_queue.front());
251 //workarea->tile_queue.pop_front();
252 int curr_tile(workarea->next_unrendered_tile(refresh_id-onion_skin_queue.size()));
256 // Width of the image(in tiles)
257 int tw(rend_desc().get_w()/get_tile_w());
258 if(rend_desc().get_w()%get_tile_w()!=0)tw++;
260 y=(curr_tile/tw)*get_tile_w();
261 x=(curr_tile%tw)*get_tile_h();
263 // Mark this tile as "up-to-date"
265 workarea->tile_book[curr_tile].second=refresh_id-onion_skin_queue.size();
267 workarea->tile_book[curr_tile].second=refresh_id;
269 return total_tiles()-curr_tile+1;
273 virtual bool start_frame(synfig::ProgressCallback */*cb*/)
275 synfig::Mutex::Lock lock(mutex);
277 int tw(rend_desc().get_w()/get_tile_w());
278 if(rend_desc().get_w()%get_tile_w()!=0)tw++;
279 int th(rend_desc().get_h()/get_tile_h());
280 if(rend_desc().get_h()%get_tile_h()!=0)th++;
287 workarea->tile_book.resize(total_tiles());
288 //tile_iter=workarea->tile_book.begin()+twindow_start;
292 static void free_buff(const guint8 *x) { free(const_cast<guint8*>(x)); }
294 virtual bool add_tile(const synfig::Surface &surface, int x, int y)
296 synfig::Mutex::Lock lock(mutex);
299 PixelFormat pf(PF_RGB);
301 const int total_bytes(get_tile_w()*get_tile_h()*synfig::channels(pf));
303 unsigned char *buffer((unsigned char*)malloc(total_bytes));
305 if(!surface || !buffer)
308 unsigned char *dest(buffer);
309 const Color *src(surface[0]);
312 int x(surface.get_w()*surface.get_h());
314 // int div = workarea->get_low_res_pixel_size();
317 Color dark(0.6,0.6,0.6);
318 Color lite(0.8,0.8,0.8);
320 dest=Color2PixelFormat(
323 ((i/surface.get_w())*8/h+(i%surface.get_w())*8/w)&1?dark:lite,
332 int tw(rend_desc().get_w()/get_tile_w());
333 if(rend_desc().get_w()%get_tile_w()!=0)tw++;
334 unsigned int index=y*tw+x;
337 if(index>workarea->tile_book.size())
340 Glib::RefPtr<Gdk::Pixbuf> pixbuf;
342 pixbuf=Gdk::Pixbuf::create_from_data(
343 buffer, // pointer to the data
344 Gdk::COLORSPACE_RGB, // the colorspace
345 ((pf&PF_A)==PF_A), // has alpha?
346 8, // bits per sample
347 surface.get_w(), // width
348 surface.get_h(), // height
349 surface.get_w()*synfig::channels(pf), // stride (pitch)
350 sigc::ptr_fun(&WorkAreaTarget::free_buff)
355 // We need to scale up
356 int div = workarea->get_low_res_pixel_size();
357 pixbuf=pixbuf->scale_simple(
364 if(!onionskin || onion_first_tile || !workarea->tile_book[index].first)
366 workarea->tile_book[index].first=pixbuf;
371 workarea->tile_book[index].first, // Dest
374 pixbuf->get_width(), // dest width
375 pixbuf->get_height(), // dest_height,
376 0, // double offset_x
377 0, // double offset_y
380 Gdk::INTERP_NEAREST, // interp
381 255/(onion_layers-onion_skin_queue.size()+1) //int overall_alpha
386 workarea->queue_draw();
387 assert(workarea->tile_book[index].first);
391 virtual void end_frame()
393 //workarea->queue_draw();
398 class studio::WorkAreaTarget_Full : public synfig::Target_Scanline
404 int real_tile_w,real_tile_h;
405 //std::vector<Glib::RefPtr<Gdk::Pixbuf> >::iterator tile_iter;
407 int twindow_start, twindow_width, twindow_height, twindow_pad;
411 bool onion_first_tile;
416 std::list<synfig::Time> onion_skin_queue;
418 void set_onion_skin(bool x, int *onions)
422 Time time(rend_desc().get_time_start());
426 onion_skin_queue.push_back(time);
427 //onion_skin_queue.push_back(time-1);
428 //onion_skin_queue.push_back(time+1);
432 for(int i=0; i<onions[0]; i++)
434 Time keytime=get_canvas()->keyframe_list().find_prev(thistime)->get_time();
435 onion_skin_queue.push_back(keytime);
445 for(int i=0; i<onions[1]; i++)
447 Time keytime=get_canvas()->keyframe_list().find_next(thistime)->get_time();
448 onion_skin_queue.push_back(keytime);
455 onion_layers=onion_skin_queue.size();
457 onion_first_tile=false;
461 WorkAreaTarget_Full(WorkArea *workarea,int w, int h):
463 low_res(workarea->get_low_resolution_flag()),
466 refresh_id(workarea->refreshes),
470 set_canvas(workarea->get_canvas());
471 set_quality(workarea->get_quality());
474 ~WorkAreaTarget_Full()
478 virtual bool set_rend_desc(synfig::RendDesc *newdesc)
481 newdesc->set_flags(RendDesc::PX_ASPECT|RendDesc::IM_SPAN);
484 int div = workarea->get_low_res_pixel_size();
485 newdesc->set_wh(w/div,h/div);
488 newdesc->set_wh(w,h);
492 || workarea->get_h()!=h
493 ) workarea->set_wh(w,h,4);
495 surface.set_wh(newdesc->get_w(),newdesc->get_h());
498 workarea->full_frame=true;
499 workarea->tile_book.resize(1);
503 virtual int next_frame(Time& time)
505 // Mark this tile as "up-to-date"
507 workarea->tile_book[0].second=refresh_id-onion_skin_queue.size();
509 workarea->tile_book[0].second=refresh_id;
512 return synfig::Target_Scanline::next_frame(time);
514 onion_first_tile=(onion_layers==(signed)onion_skin_queue.size());
516 if(!onion_skin_queue.empty())
518 time=onion_skin_queue.front();
519 onion_skin_queue.pop_front();
523 return onion_skin_queue.size()+1;
527 virtual bool start_frame(synfig::ProgressCallback */*cb*/)
532 virtual Color * start_scanline(int scanline)
534 return surface[scanline];
537 virtual bool end_scanline()
542 static void free_buff(const guint8 *x) { free(const_cast<guint8*>(x)); }
544 virtual void end_frame()
548 PixelFormat pf(PF_RGB);
550 const int total_bytes(surface.get_w()*surface.get_h()*synfig::channels(pf));
552 unsigned char *buffer((unsigned char*)malloc(total_bytes));
554 if(!surface || !buffer)
557 unsigned char *dest(buffer);
558 const Color *src(surface[0]);
559 int w(surface.get_w());
560 //int h(surface.get_h());
561 int x(surface.get_w()*surface.get_h());
563 // int div = workarea->get_low_res_pixel_size();
566 Color dark(0.6,0.6,0.6);
567 Color lite(0.8,0.8,0.8);
568 int tw=workarea->tile_w;
569 int th=workarea->tile_h;
572 int div = workarea->get_low_res_pixel_size();
577 dest=Color2PixelFormat(
580 ((i/w)*8/th+(i%w)*8/tw)&1?dark:lite,
589 Glib::RefPtr<Gdk::Pixbuf> pixbuf;
591 pixbuf=Gdk::Pixbuf::create_from_data(
592 buffer, // pointer to the data
593 Gdk::COLORSPACE_RGB, // the colorspace
594 ((pf&PF_A)==PF_A), // has alpha?
595 8, // bits per sample
596 surface.get_w(), // width
597 surface.get_h(), // height
598 surface.get_w()*synfig::channels(pf), // stride (pitch)
599 sigc::ptr_fun(&WorkAreaTarget::free_buff)
604 // We need to scale up
605 int div = workarea->get_low_res_pixel_size();
606 pixbuf=pixbuf->scale_simple(
615 if(!onionskin || onion_first_tile || !workarea->tile_book[index].first)
617 workarea->tile_book[index].first=pixbuf;
622 workarea->tile_book[index].first, // Dest
625 pixbuf->get_width(), // dest width
626 pixbuf->get_height(), // dest_height,
627 0, // double offset_x
628 0, // double offset_y
631 Gdk::INTERP_NEAREST, // interp
632 255/(onion_layers-onion_skin_queue.size()+1) //int overall_alpha
636 workarea->queue_draw();
637 assert(workarea->tile_book[index].first);
644 /* === M E T H O D S ======================================================= */
647 WorkArea::WorkArea(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface):
648 Gtk::Table(3, 3, false), /* 3 columns by 3 rows*/
649 canvas_interface(canvas_interface),
650 canvas(canvas_interface->get_canvas()),
651 scrollx_adjustment(0,-4,4,0.01,0.1),
652 scrolly_adjustment(0,-4,4,0.01,0.1),
667 allow_duck_clicks=true;
668 allow_layer_clicks=true;
669 render_idle_func_id=0;
672 low_res_pixel_size=2;
678 last_focus_point=Point(0,0);
683 dirty_trap_enabled=false;
688 meta_data_lock=false;
690 insert_renderer(new Renderer_Canvas, 000);
691 insert_renderer(new Renderer_Grid, 100);
692 insert_renderer(new Renderer_Guides, 200);
693 insert_renderer(new Renderer_Ducks, 300);
694 insert_renderer(new Renderer_BBox, 399);
695 insert_renderer(new Renderer_Dragbox, 400);
696 insert_renderer(new Renderer_Timecode, 500);
698 signal_duck_selection_changed().connect(sigc::mem_fun(*this,&studio::WorkArea::queue_draw));
699 signal_strokes_changed().connect(sigc::mem_fun(*this,&studio::WorkArea::queue_draw));
700 signal_grid_changed().connect(sigc::mem_fun(*this,&studio::WorkArea::queue_draw));
701 signal_grid_changed().connect(sigc::mem_fun(*this,&studio::WorkArea::save_meta_data));
702 signal_sketch_saved().connect(sigc::mem_fun(*this,&studio::WorkArea::save_meta_data));
704 // Not that it really makes a difference... (setting this to zero, that is)
707 drawing_area=manage(new class Gtk::DrawingArea());
708 drawing_area->show();
709 drawing_area->set_extension_events(Gdk::EXTENSION_EVENTS_ALL);
711 drawing_frame=manage(new Gtk::Frame);
712 drawing_frame->add(*drawing_area);
713 //drawing_frame->set_shadow_type(Gtk::SHADOW_NONE);
714 //drawing_frame->property_border_width()=5;
715 //drawing_frame->modify_fg(Gtk::STATE_NORMAL,Gdk::Color("#00ffff"));
716 //drawing_frame->modify_base(Gtk::STATE_NORMAL,Gdk::Color("#ff00ff"));
717 /*drawing_frame->modify_fg(Gtk::STATE_ACTIVE,Gdk::Color("#00ffff"));
718 drawing_frame->modify_base(Gtk::STATE_ACTIVE,Gdk::Color("#ff00ff"));
719 drawing_frame->modify_bg(Gtk::STATE_ACTIVE,Gdk::Color("#00ff00"));
720 drawing_frame->modify_fg(Gtk::STATE_INSENSITIVE,Gdk::Color("#00ffff"));
721 drawing_frame->modify_base(Gtk::STATE_INSENSITIVE,Gdk::Color("#ff00ff"));
722 drawing_frame->modify_bg(Gtk::STATE_INSENSITIVE,Gdk::Color("#00ff00"));
723 drawing_frame->modify_fg(Gtk::STATE_SELECTED,Gdk::Color("#00ffff"));
724 drawing_frame->modify_base(Gtk::STATE_SELECTED,Gdk::Color("#ff00ff"));
725 drawing_frame->modify_bg(Gtk::STATE_SELECTED,Gdk::Color("#00ff00"));
727 //drawing_frame->set_state(Gtk::STATE_NORMAL);
729 drawing_frame->show();
731 attach(*drawing_frame, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
733 Gtk::IconSize iconsize=Gtk::IconSize::from_name("synfig-small_icon");
736 // Create the vertical and horizontal rulers
737 vruler = manage(new class Gtk::VRuler());
738 hruler = manage(new class Gtk::HRuler());
739 vruler->set_metric(Gtk::PIXELS);
740 hruler->set_metric(Gtk::PIXELS);
741 Pango::FontDescription fd(hruler->get_style()->get_font());
742 fd.set_size(Pango::SCALE*8);
743 vruler->modify_font(fd);
744 hruler->modify_font(fd);
747 attach(*vruler, 0, 1, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
748 attach(*hruler, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
749 hruler->signal_event().connect(sigc::mem_fun(*this, &WorkArea::on_hruler_event));
750 vruler->signal_event().connect(sigc::mem_fun(*this, &WorkArea::on_vruler_event));
751 hruler->add_events(Gdk::BUTTON1_MOTION_MASK | Gdk::BUTTON2_MOTION_MASK |Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK);
752 vruler->add_events(Gdk::BUTTON1_MOTION_MASK | Gdk::BUTTON2_MOTION_MASK |Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK);
754 // Create the menu button
755 menubutton=manage(new class Gtk::Button());
756 Gtk::Arrow *arrow1 = manage(new class Gtk::Arrow(Gtk::ARROW_RIGHT, Gtk::SHADOW_OUT));
757 arrow1->set_size_request(10,10);
758 menubutton->add(*arrow1);
759 menubutton->show_all();
760 menubutton->signal_pressed().connect(sigc::mem_fun(*this, &WorkArea::popup_menu));
761 attach(*menubutton, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
763 Gtk::HBox *hbox = manage(new class Gtk::HBox(false, 0));
765 Gtk::VScrollbar *vscrollbar1 = manage(new class Gtk::VScrollbar(*get_scrolly_adjustment()));
766 Gtk::HScrollbar *hscrollbar1 = manage(new class Gtk::HScrollbar(*get_scrollx_adjustment()));
768 attach(*vscrollbar1, 2, 3, 1, 2, Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
770 ZoomDial *zoomdial=manage(new class ZoomDial(iconsize));
771 zoomdial->signal_zoom_in().connect(sigc::mem_fun(*this, &studio::WorkArea::zoom_in));
772 zoomdial->signal_zoom_out().connect(sigc::mem_fun(*this, &studio::WorkArea::zoom_out));
773 zoomdial->signal_zoom_fit().connect(sigc::mem_fun(*this, &studio::WorkArea::zoom_fit));
774 zoomdial->signal_zoom_norm().connect(sigc::mem_fun(*this, &studio::WorkArea::zoom_norm));
776 hbox->pack_end(*hscrollbar1, Gtk::PACK_EXPAND_WIDGET,0);
778 hbox->pack_start(*zoomdial, Gtk::PACK_SHRINK,0);
781 attach(*hbox, 0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
784 drawing_area->add_events(Gdk::KEY_PRESS_MASK | Gdk::KEY_RELEASE_MASK);
785 add_events(Gdk::KEY_PRESS_MASK);
786 drawing_area->add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
787 drawing_area->add_events(Gdk::BUTTON1_MOTION_MASK | Gdk::BUTTON2_MOTION_MASK |Gdk::POINTER_MOTION_MASK);
789 // ----------------- Attach signals
791 drawing_area->signal_expose_event().connect(sigc::mem_fun(*this, &WorkArea::refresh));
792 drawing_area->signal_event().connect(sigc::mem_fun(*this, &WorkArea::on_drawing_area_event));
793 drawing_area->signal_size_allocate().connect(sigc::hide(sigc::mem_fun(*this, &WorkArea::refresh_dimension_info)));
797 canvas_interface->signal_rend_desc_changed().connect(sigc::mem_fun(*this, &WorkArea::refresh_dimension_info));
798 // When either of the scrolling adjustments change, then redraw.
799 get_scrollx_adjustment()->signal_value_changed().connect(sigc::mem_fun(*this, &WorkArea::queue_scroll));
800 get_scrolly_adjustment()->signal_value_changed().connect(sigc::mem_fun(*this, &WorkArea::queue_scroll));
801 get_scrollx_adjustment()->signal_value_changed().connect(sigc::mem_fun(*this, &WorkArea::refresh_dimension_info));
802 get_scrolly_adjustment()->signal_value_changed().connect(sigc::mem_fun(*this, &WorkArea::refresh_dimension_info));
804 get_canvas()->signal_meta_data_changed("grid_size").connect(sigc::mem_fun(*this,&WorkArea::load_meta_data));
805 get_canvas()->signal_meta_data_changed("grid_snap").connect(sigc::mem_fun(*this,&WorkArea::load_meta_data));
806 get_canvas()->signal_meta_data_changed("grid_show").connect(sigc::mem_fun(*this,&WorkArea::load_meta_data));
807 get_canvas()->signal_meta_data_changed("guide_show").connect(sigc::mem_fun(*this,&WorkArea::load_meta_data));
808 get_canvas()->signal_meta_data_changed("guide_x").connect(sigc::mem_fun(*this,&WorkArea::load_meta_data));
809 get_canvas()->signal_meta_data_changed("guide_y").connect(sigc::mem_fun(*this,&WorkArea::load_meta_data));
810 get_canvas()->signal_meta_data_changed("onion_skin").connect(sigc::mem_fun(*this,&WorkArea::load_meta_data));
811 get_canvas()->signal_meta_data_changed("guide_snap").connect(sigc::mem_fun(*this,&WorkArea::load_meta_data));
812 get_canvas()->signal_meta_data_changed("sketch").connect(sigc::mem_fun(*this,&WorkArea::load_meta_data));
813 get_canvas()->signal_meta_data_changed("solid_lines").connect(sigc::mem_fun(*this,&WorkArea::load_meta_data));
816 meta_data_lock=false;
817 set_focus_point(Point(0,0));
823 String data(canvas->get_meta_data("sketch"));
826 if(!load_sketch(data))
827 load_sketch(dirname(canvas->get_file_name())+ETL_DIRECTORY_SEPARATOR+basename(data));
831 hruler->property_max_size()=double(10.0);
832 vruler->property_max_size()=double(10.0);
834 drawing_area->set_flags(drawing_area->get_flags()|Gtk::CAN_FOCUS);
837 WorkArea::~WorkArea()
841 // don't leave the render function queued if we are about to vanish;
842 // that causes crashes
843 if(render_idle_func_id)
844 render_idle_func_id=0;
847 #ifdef SINGLE_THREADED
849 WorkArea::get_updating()const
851 return App::single_threaded && async_renderer && async_renderer->updating;
855 #ifdef SINGLE_THREADED
857 WorkArea::stop_updating(bool cancel)
859 async_renderer->stop();
860 if (cancel) canceled_=true;
865 WorkArea::save_meta_data()
871 Vector s(get_grid_size());
872 canvas_interface->set_meta_data("grid_size",strprintf("%f %f",s[0],s[1]));
873 canvas_interface->set_meta_data("grid_snap",get_grid_snap()?"1":"0");
874 canvas_interface->set_meta_data("guide_snap",get_guide_snap()?"1":"0");
875 canvas_interface->set_meta_data("guide_show",get_show_guides()?"1":"0");
876 canvas_interface->set_meta_data("grid_show",show_grid?"1":"0");
877 canvas_interface->set_meta_data("onion_skin",onion_skin?"1":"0");
880 GuideList::const_iterator iter;
881 for(iter=get_guide_list_x().begin();iter!=get_guide_list_x().end();++iter)
885 data+=strprintf("%f",*iter);
888 canvas_interface->set_meta_data("guide_x",data);
891 for(iter=get_guide_list_y().begin();iter!=get_guide_list_y().end();++iter)
895 data+=strprintf("%f",*iter);
898 canvas_interface->set_meta_data("guide_y",data);
901 if(get_sketch_filename().size())
903 if(dirname(canvas->get_file_name())==dirname(get_sketch_filename()))
904 canvas_interface->set_meta_data("sketch",basename(get_sketch_filename()));
906 canvas_interface->set_meta_data("sketch",get_sketch_filename());
909 meta_data_lock=false;
913 WorkArea::load_meta_data()
921 data=canvas->get_meta_data("grid_size");
924 float gx(get_grid_size()[0]),gy(get_grid_size()[1]);
926 String::iterator iter(find(data.begin(),data.end(),' '));
927 String tmp(data.begin(),iter);
932 synfig::error("WorkArea::load_meta_data(): Unable to parse data for \"grid_size\", which was \"%s\"",data.c_str());
937 tmp=String(iter+1,data.end());
942 synfig::error("WorkArea::load_meta_data(): Unable to parse data for \"grid_size\", which was \"%s\"",data.c_str());
944 set_grid_size(Vector(gx,gy));
947 data=canvas->get_meta_data("grid_show");
948 if(data.size() && (data=="1" || data[0]=='t' || data[0]=='T'))
950 if(data.size() && (data=="0" || data[0]=='f' || data[0]=='F'))
953 data=canvas->get_meta_data("solid_lines");
954 if(data.size() && (data=="1" || data[0]=='t' || data[0]=='T'))
956 if(data.size() && (data=="0" || data[0]=='f' || data[0]=='F'))
959 data=canvas->get_meta_data("guide_show");
960 if(data.size() && (data=="1" || data[0]=='t' || data[0]=='T'))
962 if(data.size() && (data=="0" || data[0]=='f' || data[0]=='F'))
965 data=canvas->get_meta_data("grid_snap");
966 if(data.size() && (data=="1" || data[0]=='t' || data[0]=='T'))
968 if(data.size() && (data=="0" || data[0]=='f' || data[0]=='F'))
969 set_grid_snap(false);
971 data=canvas->get_meta_data("guide_snap");
972 if(data.size() && (data=="1" || data[0]=='t' || data[0]=='T'))
973 set_guide_snap(true);
974 if(data.size() && (data=="0" || data[0]=='f' || data[0]=='F'))
975 set_guide_snap(false);
977 data=canvas->get_meta_data("onion_skin");
978 if(data.size() && (data=="1" || data[0]=='t' || data[0]=='T'))
979 set_onion_skin(true);
980 if(data.size() && (data=="0" || data[0]=='f' || data[0]=='F'))
981 set_onion_skin(false);
983 data=canvas->get_meta_data("guide_x");
984 get_guide_list_x().clear();
987 String::iterator iter(find(data.begin(),data.end(),' '));
988 String guide(data.begin(),iter);
991 get_guide_list_x().push_back(stratof(guide));
996 data=String(iter+1,data.end());
998 //sort(get_guide_list_x());
1000 data=canvas->get_meta_data("guide_y");
1001 get_guide_list_y().clear();
1002 while(!data.empty())
1004 String::iterator iter(find(data.begin(),data.end(),' '));
1005 String guide(data.begin(),iter);
1008 get_guide_list_y().push_back(stratof(guide));
1010 if(iter==data.end())
1013 data=String(iter+1,data.end());
1015 //sort(get_guide_list_y());
1017 meta_data_lock=false;
1022 WorkArea::set_onion_skin(bool x)
1028 queue_render_preview();
1029 signal_onion_skin_changed()();
1033 WorkArea::get_onion_skin()const
1038 void WorkArea::set_onion_skins(int *onions)
1040 onion_skins[0]=onions[0];
1041 onion_skins[1]=onions[1];
1043 queue_render_preview();
1047 WorkArea::enable_grid()
1055 WorkArea::disable_grid()
1063 WorkArea::set_show_guides(bool x)
1071 WorkArea::toggle_grid()
1073 show_grid=!show_grid;
1079 WorkArea::set_low_resolution_flag(bool x)
1081 if(x!=low_resolution)
1084 queue_render_preview();
1089 WorkArea::toggle_low_resolution_flag()
1091 set_low_resolution_flag(!get_low_resolution_flag());
1095 WorkArea::popup_menu()
1097 signal_popup_menu()();
1101 WorkArea::set_grid_size(const synfig::Vector &s)
1103 Duckmatic::set_grid_size(s);
1109 WorkArea::set_focus_point(const synfig::Point &point)
1111 // These next three lines try to ensure that we place the
1112 // focus on a pixel boundary
1113 /*Point adjusted(point[0]/abs(get_pw()),point[1]/abs(get_ph()));
1114 adjusted[0]=(abs(adjusted[0]-floor(adjusted[0]))<0.5)?floor(adjusted[0])*abs(get_pw()):ceil(adjusted[0])*abs(get_ph());
1115 adjusted[1]=(abs(adjusted[1]-floor(adjusted[1]))<0.5)?floor(adjusted[1])*abs(get_ph()):ceil(adjusted[1])*abs(get_ph());
1117 const synfig::Point& adjusted(point);
1119 synfig::RendDesc &rend_desc(get_canvas()->rend_desc());
1120 Real x_factor=(rend_desc.get_br()[0]-rend_desc.get_tl()[0]>0)?-1:1;
1121 Real y_factor=(rend_desc.get_br()[1]-rend_desc.get_tl()[1]>0)?-1:1;
1123 get_scrollx_adjustment()->set_value(adjusted[0]*x_factor);
1124 get_scrolly_adjustment()->set_value(adjusted[1]*y_factor);
1128 WorkArea::get_focus_point()const
1130 synfig::RendDesc &rend_desc(get_canvas()->rend_desc());
1131 Real x_factor=(rend_desc.get_br()[0]-rend_desc.get_tl()[0]>0)?-1:1;
1132 Real y_factor=(rend_desc.get_br()[1]-rend_desc.get_tl()[1]>0)?-1:1;
1134 return synfig::Point(get_scrollx_adjustment()->get_value()*x_factor, get_scrolly_adjustment()->get_value()*y_factor);
1138 WorkArea::set_wh(int W, int H,int CHAN)
1140 // If our size is already set, don't set it again
1141 if(W==w && H==h && CHAN==bpp)
1145 if(W<=0 || H<=0 || CHAN<=0)
1152 // Set all of the parameters
1157 refresh_dimension_info();
1165 WorkArea::on_key_press_event(GdkEventKey* event)
1167 if(get_selected_ducks().empty())
1170 Real multiplier(1.0);
1172 if(Gdk::ModifierType(event->state)&GDK_SHIFT_MASK)
1176 switch(event->keyval)
1179 nudge=Vector(-pw,0);
1185 nudge=Vector(0,-ph);
1195 synfigapp::Action::PassiveGrouper grouper(instance.get(),_("Nudge"));
1197 // Grid snap does not apply to nudging
1198 bool grid_snap_holder(get_grid_snap());
1199 bool guide_snap_holder(get_guide_snap());
1200 set_grid_snap(false);
1203 start_duck_drag(get_selected_duck()->get_trans_point());
1204 translate_selected_ducks(get_selected_duck()->get_trans_point()+nudge*multiplier);
1209 canvas_view->duck_refresh_flag=true;
1210 canvas_view->queue_rebuild_ducks();
1213 set_grid_snap(grid_snap_holder);
1214 set_guide_snap(guide_snap_holder);
1220 WorkArea::on_drawing_area_event(GdkEvent *event)
1222 synfig::Point mouse_pos;
1223 float bezier_click_pos;
1224 const float radius((abs(pw)+abs(ph))*4);
1225 int button_pressed(0);
1227 bool is_mouse(false);
1228 Gdk::ModifierType modifier(Gdk::ModifierType(0));
1230 // Handle input stuff
1232 event->any.type==GDK_MOTION_NOTIFY ||
1233 event->any.type==GDK_BUTTON_PRESS ||
1234 event->any.type==GDK_2BUTTON_PRESS ||
1235 event->any.type==GDK_3BUTTON_PRESS ||
1236 event->any.type==GDK_BUTTON_RELEASE
1240 if(event->any.type==GDK_MOTION_NOTIFY)
1242 device=event->motion.device;
1243 modifier=Gdk::ModifierType(event->motion.state);
1247 device=event->button.device;
1248 modifier=Gdk::ModifierType(event->button.state);
1249 drawing_area->grab_focus();
1252 // Make sure we recognize the device
1253 if(curr_input_device)
1255 if(curr_input_device!=device)
1258 curr_input_device=device;
1259 signal_input_device_changed()(curr_input_device);
1264 curr_input_device=device;
1265 signal_input_device_changed()(curr_input_device);
1268 assert(curr_input_device);
1270 // Calculate the position of the
1271 // input device in canvas coordinates
1273 if(!event->button.axes)
1275 mouse_pos=synfig::Point(screen_to_comp_coords(synfig::Point(event->button.x,event->button.y)));
1276 button_pressed=event->button.button;
1279 if(isnan(event->button.x) || isnan(event->button.y))
1284 double x(event->button.axes[0]);
1285 double y(event->button.axes[1]);
1286 if(isnan(x) || isnan(y))
1289 pressure=event->button.axes[2];
1290 //synfig::info("pressure=%f",pressure);
1292 pressure/=1.0f-0.04f;
1295 assert(!isnan(pressure));
1297 mouse_pos=synfig::Point(screen_to_comp_coords(synfig::Point(x,y)));
1299 button_pressed=event->button.button;
1301 if(button_pressed==1 && pressure<0 && (event->any.type!=GDK_BUTTON_RELEASE && event->any.type!=GDK_BUTTON_PRESS))
1306 //if(event->any.type==GDK_BUTTON_PRESS && button_pressed)
1307 // synfig::info("Button pressed on input device = %d",event->button.button);
1309 //if(event->button.axes[2]>0.1)
1310 // button_pressed=1;
1312 // button_pressed=0;
1315 // GDK mouse scrolling events
1316 else if(event->any.type==GDK_SCROLL)
1318 // GDK information needed to properly interpret mouse
1319 // scrolling events are: scroll.state, scroll.x/scroll.y, and
1320 // scroll.direction. The value of scroll.direction will be
1323 modifier=Gdk::ModifierType(event->scroll.state);
1324 mouse_pos=synfig::Point(screen_to_comp_coords(synfig::Point(event->scroll.x,event->scroll.y)));
1327 // Handle the renderables
1329 std::set<etl::handle<WorkAreaRenderer> >::iterator iter;
1330 for(iter=renderer_set_.begin();iter!=renderer_set_.end();++iter)
1332 if((*iter)->get_enabled())
1333 if((*iter)->event_vfunc(event))
1335 // Event handled. Return true.
1341 // Event hasn't been handled, pass it down
1344 case GDK_BUTTON_PRESS:
1346 switch(button_pressed)
1348 case 1: // Attempt to click on a duck
1350 etl::handle<Duck> duck;
1353 if(allow_duck_clicks)
1355 duck=find_duck(mouse_pos,radius);
1359 // make a note of whether the duck we click on was selected or not
1360 if(duck_is_selected(duck))
1365 // if CTRL isn't pressed, clicking an unselected duck will unselect all other ducks
1366 if(!(modifier&GDK_CONTROL_MASK))
1367 clear_selected_ducks();
1373 // clear_selected_ducks();
1377 selected_bezier=find_bezier(mouse_pos,radius,&bezier_click_pos);
1380 if (!duck->get_editable())
1383 //get_selected_duck()->signal_user_click(0)();
1384 //if(clicked_duck)clicked_duck->signal_user_click(0)();
1386 // if the user is holding shift while clicking on a tangent duck, consider splitting the tangent
1387 if (event->motion.state&GDK_SHIFT_MASK && duck->get_type() == Duck::TYPE_TANGENT)
1389 synfigapp::ValueDesc value_desc = duck->get_value_desc();
1391 // we have the tangent, but need the vertex - that's the parent
1392 if (value_desc.parent_is_value_node()) {
1393 ValueNode_Composite::Handle parent_value_node = value_desc.get_parent_value_node();
1395 // if the tangent isn't split, then split it
1396 if (!((*(parent_value_node->get_link("split")))(get_time()).get(bool())))
1398 if (get_canvas_view()->canvas_interface()->
1399 change_value(synfigapp::ValueDesc(parent_value_node,
1400 parent_value_node->get_link_index_from_name("split")),
1403 // rebuild the ducks from scratch, so the tangents ducks aren't connected
1404 get_canvas_view()->rebuild_ducks();
1406 // reprocess the mouse click
1407 return on_drawing_area_event(event);
1413 // I don't know how to access the vertex from the tangent duck when originally drawing the bline in the bline tool
1415 // synfig::ValueNode::Handle vn = value_desc.get_value_node();
1416 synfig::info("parent isn't value node? shift-drag-tangent doesn't work in bline tool yet...");
1421 drag_point=mouse_pos;
1422 //drawing_area->queue_draw();
1423 start_duck_drag(mouse_pos);
1424 get_canvas_view()->reset_cancel_status();
1427 // I commented out this section because
1428 // it was causing issues when rotoscoping.
1429 // At the moment, we don't need it, so
1430 // this was the easiest way to fix the problem.
1436 selected_bezier->signal_user_click(0)(bezier_click_pos);
1441 //clear_selected_ducks();
1443 if(canvas_view->get_smach().process_event(EventMouse(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,BUTTON_LEFT,mouse_pos,pressure,modifier))==Smach::RESULT_OK)
1445 // Check for a guide click
1446 GuideList::iterator iter;
1448 iter=find_guide_x(mouse_pos,radius);
1449 if(iter==get_guide_list_x().end())
1451 curr_guide_is_x=false;
1452 iter=find_guide_y(mouse_pos,radius);
1455 curr_guide_is_x=true;
1456 if(iter!=get_guide_list_x().end() && iter!=get_guide_list_y().end())
1458 dragging=DRAG_GUIDE;
1464 // All else fails, try making a selection box
1466 curr_point=drag_point=mouse_pos;
1472 case 2: // Attempt to drag and move the window
1474 etl::handle<Duck> duck=find_duck(mouse_pos,radius);
1475 etl::handle<Bezier> bezier=find_bezier(mouse_pos,radius,&bezier_click_pos);
1477 duck->signal_user_click(1)();
1480 bezier->signal_user_click(1)(bezier_click_pos);
1482 if(canvas_view->get_smach().process_event(EventMouse(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,BUTTON_MIDDLE,mouse_pos,pressure,modifier))==Smach::RESULT_OK)
1485 dragging=DRAG_WINDOW;
1486 drag_point=mouse_pos;
1487 signal_user_click(1)(mouse_pos);
1491 case 3: // Attempt to either get info on a duck, or open the menu
1493 etl::handle<Duck> duck=find_duck(mouse_pos,radius);
1494 etl::handle<Bezier> bezier=find_bezier(mouse_pos,radius,&bezier_click_pos);
1496 Layer::Handle layer(get_canvas()->find_layer(mouse_pos));
1499 if(get_selected_ducks().size()<=1)
1500 duck->signal_user_click(2)();
1502 canvas_view->get_smach().process_event(EventMouse(EVENT_WORKAREA_MULTIPLE_DUCKS_CLICKED,BUTTON_RIGHT,mouse_pos,pressure,modifier));
1507 bezier->signal_user_click(2)(bezier_click_pos);
1512 if(canvas_view->get_smach().process_event(EventLayerClick(layer,BUTTON_RIGHT,mouse_pos))==Smach::RESULT_OK)
1517 canvas_view->get_smach().process_event(EventMouse(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,BUTTON_RIGHT,mouse_pos,pressure,modifier));
1519 if(canvas_view->get_smach().process_event(EventMouse(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,BUTTON_RIGHT,mouse_pos,pressure,modifier))==Smach::RESULT_OK)
1528 signal_user_click(3)(mouse_pos);
1531 signal_user_click(4)(mouse_pos);
1538 case GDK_MOTION_NOTIFY:
1539 curr_point=mouse_pos;
1541 if(event->motion.time-last_event_time<25)
1544 last_event_time=event->motion.time;
1546 signal_cursor_moved_();
1548 // Guide/Duck highlights on hover
1549 if(dragging==DRAG_NONE)
1551 GuideList::iterator iter;
1553 iter=find_guide_x(mouse_pos,radius);
1554 if(iter==get_guide_list_x().end())
1555 iter=find_guide_y(mouse_pos,radius);
1557 if(iter!=curr_guide)
1560 drawing_area->queue_draw();
1563 etl::handle<Duck> duck;
1564 duck=find_duck(mouse_pos,radius);
1565 if(duck!=hover_duck)
1568 drawing_area->queue_draw();
1573 if(dragging==DRAG_DUCK)
1575 if(canvas_view->get_cancel_status())
1578 canvas_view->queue_rebuild_ducks();
1582 Point point((mouse_pos-selected_duck->get_origin())/selected_duck->get_scalar());
1585 point[0]=floor(point[0]/grid_size[0]+0.5)*grid_size[0];
1586 point[1]=floor(point[1]/grid_size[1]+0.5)*grid_size[1];
1588 selected_duck->set_point(point);
1591 //Point p(mouse_pos);
1593 set_axis_lock(event->motion.state&GDK_SHIFT_MASK);
1595 translate_selected_ducks(mouse_pos);
1597 drawing_area->queue_draw();
1600 if(dragging==DRAG_BOX)
1602 curr_point=mouse_pos;
1603 drawing_area->queue_draw();
1606 if(dragging==DRAG_GUIDE)
1609 *curr_guide=mouse_pos[0];
1611 *curr_guide=mouse_pos[1];
1612 drawing_area->queue_draw();
1615 if(dragging!=DRAG_WINDOW)
1616 { // Update those triangle things on the rulers
1617 const synfig::Point point(mouse_pos);
1618 hruler->property_position()=Distance(point[0],Distance::SYSTEM_UNITS).get(App::distance_system,get_canvas()->rend_desc());
1619 vruler->property_position()=Distance(point[1],Distance::SYSTEM_UNITS).get(App::distance_system,get_canvas()->rend_desc());
1622 if(dragging == DRAG_WINDOW)
1623 set_focus_point(get_focus_point() + mouse_pos-drag_point);
1624 else if (event->motion.state & GDK_BUTTON1_MASK &&
1625 canvas_view->get_smach().process_event(EventMouse(EVENT_WORKAREA_MOUSE_BUTTON_DRAG, BUTTON_LEFT,
1626 mouse_pos,pressure,modifier)) == Smach::RESULT_ACCEPT)
1628 else if (event->motion.state & GDK_BUTTON2_MASK &&
1629 canvas_view->get_smach().process_event(EventMouse(EVENT_WORKAREA_MOUSE_BUTTON_DRAG, BUTTON_MIDDLE,
1630 mouse_pos, pressure, modifier)) == Smach::RESULT_ACCEPT)
1632 else if (event->motion.state & GDK_BUTTON3_MASK &&
1633 canvas_view->get_smach().process_event(EventMouse(EVENT_WORKAREA_MOUSE_BUTTON_DRAG, BUTTON_RIGHT,
1634 mouse_pos, pressure, modifier)) == Smach::RESULT_ACCEPT)
1636 else if(canvas_view->get_smach().process_event(EventMouse(EVENT_WORKAREA_MOUSE_MOTION, BUTTON_NONE,
1637 mouse_pos, pressure,modifier)) == Smach::RESULT_ACCEPT)
1642 case GDK_BUTTON_RELEASE:
1646 if(dragging==DRAG_GUIDE)
1653 if(dragging==DRAG_DUCK)
1655 synfigapp::Action::PassiveGrouper grouper(instance.get(),_("Move"));
1657 //translate_selected_ducks(mouse_pos);
1658 set_axis_lock(false);
1661 get_canvas_view()->duck_refresh_flag=false;
1662 get_canvas_view()->duck_refresh_needed=false;
1663 const bool drag_did_anything(end_duck_drag());
1664 get_canvas_view()->duck_refresh_flag=true;
1665 if(!drag_did_anything)
1667 // if we originally clicked on a selected duck ...
1670 // ... and CTRL is pressed, then just toggle the clicked duck
1671 // otherwise make the clicked duck the only selected duck
1672 if(modifier&GDK_CONTROL_MASK)
1673 unselect_duck(clicked_duck);
1676 clear_selected_ducks();
1677 select_duck(clicked_duck);
1679 clicked_duck->signal_user_click(0)();
1684 if(canvas_view->duck_refresh_needed)
1685 canvas_view->queue_rebuild_ducks();
1690 canvas_view->duck_refresh_flag=true;
1691 canvas_view->queue_rebuild_ducks();
1700 if(dragging==DRAG_BOX)
1703 if((drag_point-mouse_pos).mag()>radius/2.0f)
1705 if(canvas_view->get_smach().process_event(EventBox(drag_point,mouse_pos,MouseButton(event->button.button),modifier))==Smach::RESULT_ACCEPT)
1708 // when dragging a box around some ducks:
1709 // SHIFT selects; CTRL toggles; SHIFT+CTRL unselects; <none> clears all then selects
1710 if(modifier&GDK_SHIFT_MASK)
1711 select_ducks_in_box(drag_point,mouse_pos);
1713 if(modifier&GDK_CONTROL_MASK)
1714 toggle_select_ducks_in_box(drag_point,mouse_pos);
1715 else if(!(modifier&GDK_SHIFT_MASK))
1717 clear_selected_ducks();
1718 select_ducks_in_box(drag_point,mouse_pos);
1724 if(allow_layer_clicks)
1726 Layer::Handle layer(get_canvas()->find_layer(drag_point));
1729 if(canvas_view->get_smach().process_event(EventLayerClick(layer,BUTTON_LEFT,mouse_pos,modifier))==Smach::RESULT_OK)
1730 signal_layer_selected_(layer);
1736 signal_user_click(0)(mouse_pos);
1743 if(canvas_view->get_smach().process_event(EventMouse(EVENT_WORKAREA_MOUSE_BUTTON_UP,MouseButton(event->button.button),mouse_pos,pressure,modifier))==Smach::RESULT_ACCEPT)
1751 // Handle a mouse scrolling event like Xara Xtreme and
1754 // Scroll up/down: scroll up/down
1755 // Shift + scroll up/down: scroll left/right
1756 // Control + scroll up/down: zoom in/out
1758 if(modifier&GDK_CONTROL_MASK)
1761 // The zoom is performed while preserving the pointer
1762 // position as a fixed point (similarly to Xara Xtreme and
1765 // The strategy used below is to scroll to the updated
1766 // position, then zoom. This is easy to implement within
1767 // the present architecture, but has the disadvantage of
1768 // triggering multiple visible refreshes. Note: 1.25 is
1769 // the hard wired ratio in zoom_in()/zoom_out(). The
1770 // variable "drift" compensates additional inaccuracies in
1771 // the zoom. There is also an additional minus sign for
1772 // the inverted y coordinates.
1774 // FIXME: One might want to figure out where in the code
1775 // this empirical drift is been introduced.
1777 const synfig::Point scroll_point(get_scrollx_adjustment()->get_value(),get_scrolly_adjustment()->get_value());
1778 const double drift = 0.052;
1780 switch(event->scroll.direction)
1783 case GDK_SCROLL_RIGHT:
1784 get_scrollx_adjustment()->set_value(scroll_point[0]+(mouse_pos[0]-scroll_point[0])*(1.25-(1+drift)));
1785 get_scrolly_adjustment()->set_value(scroll_point[1]-(mouse_pos[1]+scroll_point[1])*(1.25-(1+drift)));
1788 case GDK_SCROLL_DOWN:
1789 case GDK_SCROLL_LEFT:
1790 get_scrollx_adjustment()->set_value(scroll_point[0]+(mouse_pos[0]-scroll_point[0])*(1/1.25-(1+drift)));
1791 get_scrolly_adjustment()->set_value(scroll_point[1]-(mouse_pos[1]+scroll_point[1])*(1/1.25-(1+drift)));
1798 else if(modifier&GDK_SHIFT_MASK)
1800 // Scroll in either direction by 20 pixels. Ideally, the
1801 // amount of pixels per scrolling event should be
1802 // configurable. Xara Xtreme currently uses an (hard
1803 // wired) amount 20 pixel, Inkscape defaults to 40 pixels.
1805 const int scroll_pixel = 20;
1807 switch(event->scroll.direction)
1810 get_scrollx_adjustment()->set_value(get_scrollx_adjustment()->get_value()-scroll_pixel*pw);
1812 case GDK_SCROLL_DOWN:
1813 get_scrollx_adjustment()->set_value(get_scrollx_adjustment()->get_value()+scroll_pixel*pw);
1815 case GDK_SCROLL_LEFT:
1816 get_scrolly_adjustment()->set_value(get_scrolly_adjustment()->get_value()+scroll_pixel*ph);
1818 case GDK_SCROLL_RIGHT:
1819 get_scrolly_adjustment()->set_value(get_scrolly_adjustment()->get_value()-scroll_pixel*ph);
1827 // Scroll in either direction by 20 pixels. Ideally, the
1828 // amount of pixels per scrolling event should be
1829 // configurable. Xara Xtreme currently uses an (hard
1830 // wired) amount 20 pixel, Inkscape defaults to 40 pixels.
1832 const int scroll_pixel = 20;
1834 switch(event->scroll.direction)
1837 get_scrolly_adjustment()->set_value(get_scrolly_adjustment()->get_value()+scroll_pixel*ph);
1839 case GDK_SCROLL_DOWN:
1840 get_scrolly_adjustment()->set_value(get_scrolly_adjustment()->get_value()-scroll_pixel*ph);
1842 case GDK_SCROLL_LEFT:
1843 get_scrollx_adjustment()->set_value(get_scrollx_adjustment()->get_value()-scroll_pixel*pw);
1845 case GDK_SCROLL_RIGHT:
1846 get_scrollx_adjustment()->set_value(get_scrollx_adjustment()->get_value()+scroll_pixel*pw);
1861 WorkArea::on_hruler_event(GdkEvent */*event*/)
1866 case GDK_BUTTON_PRESS:
1867 if(dragging==DRAG_NONE)
1869 dragging=DRAG_GUIDE;
1870 curr_guide=get_guide_list_y().insert(get_guide_list_y().begin());
1871 curr_guide_is_x=false;
1876 case GDK_MOTION_NOTIFY:
1878 if(dragging==DRAG_GUIDE && curr_guide_is_x==false)
1881 if(event->button.axes)
1883 x=(event->button.axes[0]);
1884 y=(event->button.axes[1]);
1892 if(isnan(y) || isnan(x))
1895 *curr_guide=synfig::Point(screen_to_comp_coords(synfig::Point(x,y)))[1];
1902 case GDK_BUTTON_RELEASE:
1903 if(dragging==DRAG_GUIDE && curr_guide_is_x==false)
1906 get_guide_list_y().erase(curr_guide);
1918 WorkArea::on_vruler_event(GdkEvent */*event*/)
1923 case GDK_BUTTON_PRESS:
1924 if(dragging==DRAG_NONE)
1926 dragging=DRAG_GUIDE;
1927 curr_guide=get_guide_list_x().insert(get_guide_list_x().begin());
1928 curr_guide_is_x=true;
1932 case GDK_BUTTON_RELEASE:
1933 if(dragging==DRAG_GUIDE && curr_guide_is_x==true)
1936 get_guide_list_x().erase(curr_guide);
1949 WorkArea::refresh_dimension_info()
1951 synfig::RendDesc &rend_desc(get_canvas()->rend_desc());
1953 canvaswidth=rend_desc.get_br()[0]-rend_desc.get_tl()[0];
1954 canvasheight=rend_desc.get_br()[1]-rend_desc.get_tl()[1];
1959 scrollx_adjustment.set_page_increment(abs(get_grid_size()[0]));
1960 scrollx_adjustment.set_step_increment(abs(pw));
1961 scrollx_adjustment.set_lower(-abs(canvaswidth));
1962 scrollx_adjustment.set_upper(abs(canvaswidth));
1963 scrolly_adjustment.set_lower(-abs(canvasheight));
1964 scrolly_adjustment.set_upper(abs(canvasheight));
1965 scrolly_adjustment.set_step_increment(abs(ph));
1966 scrolly_adjustment.set_page_increment(abs(get_grid_size()[1]));
1970 if(drawing_area->get_width()<=0 || drawing_area->get_height()<=0 || w==0 || h==0)
1973 const synfig::Point focus_point(get_focus_point());
1974 const synfig::Real x(focus_point[0]/pw+drawing_area->get_width()/2-w/2);
1975 const synfig::Real y(focus_point[1]/ph+drawing_area->get_height()/2-h/2);
1977 window_tl[0]=rend_desc.get_tl()[0]-pw*x;
1978 window_br[0]=rend_desc.get_br()[0]+pw*(drawing_area->get_width()-x-w);
1980 window_tl[1]=rend_desc.get_tl()[1]-ph*y;
1981 window_br[1]=rend_desc.get_br()[1]+ph*(drawing_area->get_height()-y-h);
1983 hruler->property_lower()=Distance(window_tl[0],Distance::SYSTEM_UNITS).get(App::distance_system,rend_desc);
1984 hruler->property_upper()=Distance(window_br[0],Distance::SYSTEM_UNITS).get(App::distance_system,rend_desc);
1985 vruler->property_lower()=Distance(window_tl[1],Distance::SYSTEM_UNITS).get(App::distance_system,rend_desc);
1986 vruler->property_upper()=Distance(window_br[1],Distance::SYSTEM_UNITS).get(App::distance_system,rend_desc);
1988 view_window_changed();
1993 WorkArea::screen_to_comp_coords(synfig::Point pos)const
1995 synfig::RendDesc &rend_desc(get_canvas()->rend_desc());
1996 //synfig::Vector::value_type canvaswidth=rend_desc.get_br()[0]-rend_desc.get_tl()[0];
1997 //synfig::Vector::value_type canvasheight=rend_desc.get_br()[1]-rend_desc.get_tl()[1];
1998 //synfig::Vector::value_type pw=canvaswidth/w;
1999 //synfig::Vector::value_type ph=canvasheight/h;
2000 Vector focus_point=get_focus_point();
2001 synfig::Vector::value_type x=focus_point[0]/pw+drawing_area->get_width()/2-w/2;
2002 synfig::Vector::value_type y=focus_point[1]/ph+drawing_area->get_height()/2-h/2;
2004 return rend_desc.get_tl()-synfig::Point(pw*x,ph*y)+synfig::Point(pw*pos[0],ph*pos[1]);
2008 WorkArea::comp_to_screen_coords(synfig::Point /*pos*/)const
2010 synfig::warning("WorkArea::comp_to_screen_coords: Not yet implemented");
2011 return synfig::Point();
2015 WorkArea::next_unrendered_tile(int refreshes)const
2017 //assert(!tile_book.empty());
2018 if(tile_book.empty())
2021 //const synfig::RendDesc &rend_desc(get_canvas()->rend_desc());
2023 const synfig::Vector focus_point(get_focus_point());
2025 // Calculate the window coordinates of the top-left
2026 // corner of the canvas.
2027 const synfig::Vector::value_type
2028 x(focus_point[0]/pw+drawing_area->get_width()/2-w/2),
2029 y(focus_point[1]/ph+drawing_area->get_height()/2-h/2);
2031 int div = low_res_pixel_size;
2032 const int width_in_tiles(w/tile_w+((low_resolution?((w/div)%(tile_w/div)):(w%tile_w))?1:0));
2033 const int height_in_tiles(h/tile_h+(h%tile_h?1:0));
2039 u2(int((-x+drawing_area->get_width())/tile_w+1)),
2040 v2(int((-y+drawing_area->get_height())/tile_h+1));
2042 if(u2>width_in_tiles)u2=width_in_tiles;
2043 if(v2>height_in_tiles)v2=height_in_tiles;
2047 int last_good_tile(-1);
2052 int index(v*width_in_tiles+u);
2053 if(tile_book[index].second<refreshes)
2055 last_good_tile=index;
2060 return last_good_tile;
2064 template <typename F, typename T=WorkAreaRenderer, typename R=typename F::result_type>
2065 class handle2ptr_t : public std::unary_function<typename etl::handle<T>,R>
2070 handle2ptr_t(const F &func):func(func) { };
2072 R operator()(typename etl::handle<T> x) { return func(*x); }
2075 template <typename F>
2079 return handle2ptr_t<F>(func);
2082 renderer_set_.begin(),
2083 renderer_set_.end(),
2088 &WorkAreaRenderer::render_vfunc
2090 Gdk::Rectangle(event->area)
2092 drawing_area->get_window()
2099 WorkArea::refresh(GdkEventExpose*event)
2101 assert(get_canvas());
2103 drawing_area->get_window()->clear();
2105 //const synfig::RendDesc &rend_desc(get_canvas()->rend_desc());
2107 const synfig::Vector focus_point(get_focus_point());
2109 // Update the old focus point
2110 last_focus_point=focus_point;
2112 // Draw out the renderables
2114 std::set<etl::handle<WorkAreaRenderer> >::iterator iter;
2115 for(iter=renderer_set_.begin();iter!=renderer_set_.end();++iter)
2117 if((*iter)->get_enabled())
2118 (*iter)->render_vfunc(
2119 drawing_area->get_window(),
2120 Gdk::Rectangle(&event->area)
2125 // Calculate the window coordinates of the top-left
2126 // corner of the canvas.
2127 //const synfig::Vector::value_type
2128 // x(focus_point[0]/pw+drawing_area->get_width()/2-w/2),
2129 // y(focus_point[1]/ph+drawing_area->get_height()/2-h/2);
2131 //const synfig::Vector::value_type window_startx(window_tl[0]);
2132 //const synfig::Vector::value_type window_endx(window_br[0]);
2133 //const synfig::Vector::value_type window_starty(window_tl[1]);
2134 //const synfig::Vector::value_type window_endy(window_br[1]);
2136 Glib::RefPtr<Gdk::GC> gc=Gdk::GC::create(drawing_area->get_window());
2138 // If we are in animate mode, draw a red border around the screen
2139 if(canvas_interface->get_mode()&synfigapp::MODE_ANIMATE)
2141 // #define USE_FRAME_BACKGROUND_TO_SHOW_EDIT_MODE
2142 #ifdef USE_FRAME_BACKGROUND_TO_SHOW_EDIT_MODE
2143 // This method of drawing the red border doesn't work on any
2144 // Gtk theme which uses the crux-engine, hcengine, industrial,
2145 // mist, or ubuntulooks engine, such as the default ubuntu
2147 drawing_frame->modify_bg(Gtk::STATE_NORMAL,Gdk::Color("#FF0000"));
2149 // So let's do it in a more primitive fashion.
2150 gc->set_rgb_fg_color(Gdk::Color("#FF0000"));
2151 gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
2152 drawing_area->get_window()->draw_rectangle(
2156 drawing_area->get_width()-1,drawing_area->get_height()-1); // w,h
2159 #ifdef USE_FRAME_BACKGROUND_TO_SHOW_EDIT_MODE
2161 drawing_frame->unset_bg(Gtk::STATE_NORMAL);
2168 WorkArea::done_rendering()
2174 pix_buf=Gdk::Pixbuf::create_from_data(
2175 buffer, // pointer to the data
2176 Gdk::COLORSPACE_RGB, // the colorspace
2178 8, // bits per sample
2181 w*bpp); // stride (pitch)
2188 WorkArea::set_quality(int x)
2193 queue_render_preview();
2197 WorkArea::set_low_res_pixel_size(int x)
2199 if(x==low_res_pixel_size)
2201 low_res_pixel_size=x;
2202 queue_render_preview();
2207 class WorkAreaProgress : public synfig::ProgressCallback
2209 WorkArea *work_area;
2210 ProgressCallback *cb;
2214 WorkAreaProgress(WorkArea *work_area,ProgressCallback *cb):
2215 work_area(work_area),cb(cb)
2221 task(const std::string &str)
2223 if(work_area->dirty)
2225 return cb->task(str);
2229 error(const std::string &err)
2231 if(work_area->dirty)
2233 return cb->error(err);
2237 amount_complete(int current, int total)
2239 if(work_area->dirty)
2241 return cb->amount_complete(current,total);
2247 studio::WorkArea::async_update_preview()
2249 #ifdef SINGLE_THREADED
2253 queue_render_preview();
2262 get_canvas_view()->reset_cancel_status();
2264 // This object will mark us as busy until
2266 //studio::App::Busy busy;
2268 //WorkAreaProgress callback(this,get_canvas_view()->get_ui_interface().get());
2269 //synfig::ProgressCallback *cb=&callback;
2271 if(!is_visible())return false;
2274 // If we are queued to render the scene at the next idle
2275 // go ahead and de-queue it.
2276 if(render_idle_func_id)
2278 g_source_remove(render_idle_func_id);
2280 render_idle_func_id=0;
2285 get_canvas_view()->reset_cancel_status();
2288 RendDesc desc=get_canvas()->rend_desc();
2290 int w=(int)(desc.get_w()*zoom);
2291 int h=(int)(desc.get_h()*zoom);
2293 // ensure that the size we draw is at least one pixel in each dimension
2294 int min_size = low_resolution ? low_res_pixel_size : 1;
2295 if (w < min_size) w = min_size;
2296 if (h < min_size) h = min_size;
2298 // Setup the description parameters
2299 desc.set_antialias(1);
2300 desc.set_time(cur_time);
2302 set_rend_desc(desc);
2304 // Create the render target
2305 handle<Target> target;
2307 // if we have lots of pixels to render and the tile renderer isn't disabled, use it
2309 div = low_resolution ? low_res_pixel_size : 1;
2310 if ((w*h > 240*div*135*div && !getenv("SYNFIG_DISABLE_TILE_RENDER")) || getenv("SYNFIG_FORCE_TILE_RENDER"))
2313 handle<WorkAreaTarget> trgt(new class WorkAreaTarget(this,w,h));
2315 trgt->set_rend_desc(&desc);
2316 trgt->set_onion_skin(get_onion_skin(), onion_skins);
2321 // do a scanline render
2322 handle<WorkAreaTarget_Full> trgt(new class WorkAreaTarget_Full(this,w,h));
2324 trgt->set_rend_desc(&desc);
2325 trgt->set_onion_skin(get_onion_skin(), onion_skins);
2329 // We can rest assured that our time has already
2330 // been set, so there is no need to have to
2331 // recalculate that over again.
2332 // UPDATE: This is kind of needless with
2333 // the way that time is handled now in SYNFIG.
2334 //target->set_avoid_time_sync(true);
2335 async_renderer=new AsyncRenderer(target);
2336 async_renderer->signal_finished().connect(
2337 sigc::mem_fun(this,&WorkArea::async_update_finished)
2341 async_renderer->start();
2343 synfig::ProgressCallback *cb=get_canvas_view()->get_ui_interface().get();
2346 cb->task(_("Rendering..."));
2353 studio::WorkArea::async_update_finished()
2355 synfig::ProgressCallback *cb=get_canvas_view()->get_ui_interface().get();
2362 // If we completed successfully, then
2363 // we aren't dirty anymore
2364 if(async_renderer->has_success())
2368 cb->task(_("Idle"));
2373 cb->task(_("Render Failed"));
2375 //get_canvas_view()->reset_cancel_status();
2380 studio::WorkArea::sync_update_preview()
2382 // const Time &time(cur_time);
2385 get_canvas_view()->reset_cancel_status();
2390 // This object will mark us as busy until
2392 studio::App::Busy busy;
2394 WorkAreaProgress callback(this,get_canvas_view()->get_ui_interface().get());
2395 synfig::ProgressCallback *cb=&callback;
2397 // We don't want to render if we are already rendering
2404 if(!is_visible())return false;
2405 get_canvas()->set_time(get_time());
2406 get_canvas_view()->get_smach().process_event(EVENT_REFRESH_DUCKS);
2407 signal_rendering()();
2409 // If we are queued to render the scene at the next idle
2410 // go ahead and de-queue it.
2411 if(render_idle_func_id)
2413 g_source_remove(render_idle_func_id);
2415 render_idle_func_id=0;
2421 get_canvas_view()->reset_cancel_status();
2423 RendDesc desc=get_canvas()->rend_desc();
2424 //newdesc->set_flags(RendDesc::PX_ASPECT|RendDesc::IM_SPAN);
2426 int w=(int)(desc.get_w()*zoom);
2427 int h=(int)(desc.get_h()*zoom);
2429 // Setup the description parameters
2430 desc.set_antialias(1);
2431 desc.set_time(cur_time);
2434 set_rend_desc(desc);
2436 // Create the render target
2437 handle<WorkAreaTarget> target(new class WorkAreaTarget(this,w,h));
2439 target->set_rend_desc(&desc);
2441 // We can rest assured that our time has already
2442 // been set, so there is no need to have to
2443 // recalculate that over again.
2444 target->set_avoid_time_sync(true);
2447 cb->task(strprintf(_("Rendering canvas %s..."),get_canvas()->get_name().c_str()));
2449 bool ret = target->render(cb);
2451 if(!ret && !get_canvas_view()->get_cancel_status() && dirty)
2457 if(get_canvas_view()->get_cancel_status())
2463 cb->task(_("Idle"));
2465 cb->task(_("Render Failed"));
2466 cb->amount_complete(0,1);
2469 // Refresh the work area to make sure that
2470 // it is being displayed correctly
2471 drawing_area->queue_draw();
2473 // If we completed successfully, then
2474 // we aren't dirty anymore
2482 //get_canvas_view()->reset_cancel_status();
2488 studio::WorkArea::async_render_preview(synfig::Time time)
2491 //tile_book.clear();
2494 if(!is_visible())return;
2496 get_canvas()->set_time(get_time());
2497 get_canvas_view()->get_smach().process_event(EVENT_REFRESH_DUCKS);
2498 signal_rendering()();
2500 async_update_preview();
2503 WorkArea::async_render_preview()
2505 return async_render_preview(get_canvas_view()->get_time());
2509 studio::WorkArea::sync_render_preview(synfig::Time time)
2512 //tile_book.clear();
2514 if(!is_visible())return false;
2515 return sync_update_preview();
2519 WorkArea::sync_render_preview()
2521 return sync_render_preview(get_canvas_view()->get_time());
2525 WorkArea::sync_render_preview_hook()
2527 sync_render_preview(get_canvas_view()->get_time());
2531 WorkArea::queue_scroll()
2533 // const synfig::RendDesc &rend_desc(get_canvas()->rend_desc());
2535 const synfig::Point focus_point(get_focus_point());
2538 new_x(focus_point[0]/pw+drawing_area->get_width()/2-w/2),
2539 new_y(focus_point[1]/ph+drawing_area->get_height()/2-h/2);
2542 old_x(last_focus_point[0]/pw+drawing_area->get_width()/2-w/2),
2543 old_y(last_focus_point[1]/ph+drawing_area->get_height()/2-h/2);
2545 // If the coordinates didn't change, we shouldn't queue a draw
2546 if(old_x==new_x && old_y==new_y)
2550 dx(round_to_int(old_x)-round_to_int(new_x)),
2551 dy(round_to_int(old_y)-round_to_int(new_y));
2553 drawing_area->get_window()->scroll(-dx,-dy);
2555 if (timecode_width && timecode_height)
2557 drawing_area->queue_draw_area(4, 4, 4+timecode_width, 4+timecode_height);
2558 drawing_area->queue_draw_area(4-dx, 4-dy, 4-dx+timecode_width, 4-dy+timecode_height);
2561 #ifndef USE_FRAME_BACKGROUND_TO_SHOW_EDIT_MODE
2562 if(canvas_interface->get_mode()&synfigapp::MODE_ANIMATE)
2564 int maxx = drawing_area->get_width()-1;
2565 int maxy = drawing_area->get_height()-1;
2569 drawing_area->queue_draw_area( 0, 0, 1, maxy);
2570 drawing_area->queue_draw_area(maxx-dx, 0, maxx-dx, maxy);
2574 drawing_area->queue_draw_area( maxx, 0, maxx, maxy);
2575 drawing_area->queue_draw_area( -dx, 0, -dx, maxy);
2579 drawing_area->queue_draw_area(0, 0, maxx, 1);
2580 drawing_area->queue_draw_area(0, maxy-dy, maxx, maxy-dy);
2584 drawing_area->queue_draw_area(0, maxy, maxx, maxy);
2585 drawing_area->queue_draw_area(0, -dy, maxx, -dy);
2588 #endif // USE_FRAME_BACKGROUND_TO_SHOW_EDIT_MODE
2590 last_focus_point=focus_point;
2594 studio::WorkArea::zoom_in()
2596 set_zoom(zoom*1.25);
2600 studio::WorkArea::zoom_out()
2602 set_zoom(zoom/1.25);
2606 studio::WorkArea::zoom_fit()
2608 float new_zoom(min(drawing_area->get_width() * zoom / w,
2609 drawing_area->get_height() * zoom / h) * 0.995);
2610 if (zoom / new_zoom > 0.995 && new_zoom / zoom > 0.995)
2612 set_zoom(prev_zoom);
2613 return set_focus_point(previous_focus);
2615 previous_focus = get_focus_point();
2618 set_focus_point(Point(0,0));
2622 studio::WorkArea::zoom_norm()
2624 if (zoom == 1.0) return set_zoom(prev_zoom);
2630 studio::WorkArea::__render_preview(gpointer data)
2632 WorkArea *work_area(static_cast<WorkArea*>(data));
2634 // there's no point anyone trying to cancel the timer now - it's gone off already
2635 work_area->render_idle_func_id = 0;
2637 work_area->queued=false;
2638 work_area->async_render_preview(work_area->get_canvas_view()->get_time());
2644 studio::WorkArea::queue_render_preview()
2646 //synfig::info("queue_render_preview(): called for %s", get_canvas_view()->get_time().get_string().c_str());
2651 //synfig::info("queue_render_preview(): already queued, unqueuing");
2652 /* if(render_idle_func_id)
2653 g_source_remove(render_idle_func_id);
2654 render_idle_func_id=0;
2660 if(dirty_trap_enabled)
2662 dirty_trap_queued++;
2674 //synfig::info("queue_render_preview(): (re)queuing...");
2675 //render_idle_func_id=g_idle_add_full(G_PRIORITY_DEFAULT,__render_preview,this,NULL);
2676 render_idle_func_id=g_timeout_add_full(
2677 G_PRIORITY_DEFAULT, // priority -
2678 queue_time, // interval - the time between calls to the function, in milliseconds (1/1000ths of a second)
2679 __render_preview, // function - function to call
2680 this, // data - data to pass to function
2681 NULL); // notify - function to call when the idle is removed, or NULL
2684 /* else if(rendering)
2693 DirtyTrap::DirtyTrap(WorkArea *work_area):work_area(work_area)
2695 work_area->dirty_trap_enabled=true;
2697 work_area->dirty_trap_queued=0;
2700 DirtyTrap::~DirtyTrap()
2702 work_area->dirty_trap_enabled=false;
2703 if(work_area->dirty_trap_queued)
2704 work_area->queue_render_preview();
2708 studio::WorkArea::queue_draw_preview()
2710 drawing_area->queue_draw();
2714 studio::WorkArea::set_cursor(const Gdk::Cursor& x)
2716 drawing_area->get_window()->set_cursor(x);
2719 studio::WorkArea::set_cursor(Gdk::CursorType x)
2721 drawing_area->get_window()->set_cursor(Gdk::Cursor(x));
2724 #include "iconcontroller.h"
2727 studio::WorkArea::refresh_cursor()
2729 // set_cursor(IconController::get_tool_cursor(canvas_view->get_smach().get_state_name(),drawing_area->get_window()));
2733 studio::WorkArea::reset_cursor()
2735 drawing_area->get_window()->set_cursor(Gdk::Cursor(Gdk::TOP_LEFT_ARROW));
2736 // set_cursor(Gdk::TOP_LEFT_ARROW);
2740 studio::WorkArea::set_zoom(float z)
2742 z=max(1.0f/128.0f,min(128.0f,z));
2746 refresh_dimension_info();
2747 /*if(async_renderer)
2749 async_renderer->stop();
2753 async_update_preview();
2754 //queue_render_preview();
2758 WorkArea::set_selected_value_node(etl::loose_handle<synfig::ValueNode> x)
2760 if(x!=selected_value_node_)
2762 selected_value_node_=x;
2768 WorkArea::insert_renderer(const etl::handle<WorkAreaRenderer> &x)
2770 renderer_set_.insert(x);
2771 x->set_work_area(this);
2776 WorkArea::insert_renderer(const etl::handle<WorkAreaRenderer> &x, int priority)
2778 x->set_priority(priority);
2783 WorkArea::erase_renderer(const etl::handle<WorkAreaRenderer> &x)
2785 x->set_work_area(0);
2786 renderer_set_.erase(x);
2791 WorkArea::resort_render_set()
2793 std::set<etl::handle<WorkAreaRenderer> > tmp(
2794 renderer_set_.begin(),
2797 renderer_set_.swap(tmp);