1 /* === S Y N F I G ========================================================= */
2 /*! \file canvasview.cpp
3 ** \brief Template File
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 ** Copyright (c) 2007 Chris Moore
11 ** This package is free software; you can redistribute it and/or
12 ** modify it under the terms of the GNU General Public License as
13 ** published by the Free Software Foundation; either version 2 of
14 ** the License, or (at your option) any later version.
16 ** This package is distributed in the hope that it will be useful,
17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ** General Public License for more details.
22 /* ========================================================================= */
24 /* === H E A D E R S ======================================================= */
33 #include <sigc++/adaptors/hide.h>
38 #include <gtkmm/paned.h>
39 #include <gtkmm/scale.h>
40 #include <gtkmm/dialog.h>
41 #include <gtkmm/messagedialog.h>
42 #include <gtkmm/treemodelsort.h>
43 #include <gtkmm/buttonbox.h>
45 #include <gtk/gtktreestore.h>
46 #include <gtk/gtkversion.h>
48 #include <synfig/valuenode_reference.h>
49 #include <synfig/valuenode_subtract.h>
50 #include <synfig/valuenode_linear.h>
51 #include <synfig/valuenode_timedswap.h>
52 #include <synfig/valuenode_scale.h>
53 #include <synfig/valuenode_dynamiclist.h>
54 #include <synfig/valuenode_twotone.h>
55 #include <synfig/valuenode_stripes.h>
56 #include <synfig/layer.h>
58 #include <synfigapp/uimanager.h>
59 #include <synfigapp/canvasinterface.h>
60 #include <synfigapp/selectionmanager.h>
61 //#include <synfigapp/action_setwaypoint.h>
62 //#include <synfigapp/action_deletewaypoint.h>
64 #include <sigc++/retype_return.h>
65 #include <sigc++/retype.h>
66 //#include <sigc++/hide.h>
68 #include "canvasview.h"
71 #include "cellrenderer_value.h"
72 #include "cellrenderer_timetrack.h"
74 #include "dialog_color.h"
77 #include "state_polygon.h"
78 #include "state_bline.h"
79 #include "state_normal.h"
80 #include "state_eyedrop.h"
81 #include "state_draw.h"
83 #include "ducktransform_scale.h"
84 #include "ducktransform_translate.h"
85 #include "ducktransform_rotate.h"
87 #include "event_mouse.h"
88 #include "event_layerclick.h"
92 #include "dialog_preview.h"
93 #include "dialog_soundselect.h"
96 #include "audiocontainer.h"
97 #include "widget_timeslider.h"
99 #include <synfigapp/main.h>
100 #include <synfigapp/inputdevice.h>
106 /* === U S I N G =========================================================== */
110 using namespace synfig;
111 using namespace studio;
112 using namespace sigc;
114 /* === M A C R O S ========================================================= */
116 #define GRAB_HINT_DATA(y) { \
118 if(synfigapp::Main::settings().get_value(String("pref.")+y+"_hints",x)) \
120 set_type_hint((Gdk::WindowTypeHint)atoi(x.c_str())); \
124 #define DEFAULT_TIME_WINDOW_SIZE (10.0)
127 #define SMALL_BUTTON(button,stockid,tooltip) \
128 button = manage(new class Gtk::Button()); \
129 icon=manage(new Gtk::Image(Gtk::StockID(stockid),iconsize)); \
130 button->add(*icon); \
131 tooltips.set_tip(*button,tooltip); \
132 icon->set_padding(0,0);\
134 button->set_relief(Gtk::RELIEF_NONE); \
138 #ifndef NORMAL_BUTTON
139 #define NORMAL_BUTTON(button,stockid,tooltip) \
140 button = manage(new class Gtk::Button()); \
141 icon=manage(new Gtk::Image(Gtk::StockID(stockid),Gtk::ICON_SIZE_BUTTON)); \
142 button->add(*icon); \
143 tooltips.set_tip(*button,tooltip); \
144 icon->set_padding(0,0);\
146 /*button->set_relief(Gtk::RELIEF_NONE);*/ \
150 #define NEW_SMALL_BUTTON(x,y,z) Gtk::Button *SMALL_BUTTON(x,y,z)
152 #define NOT_IMPLEMENTED_SLOT sigc::mem_fun(*reinterpret_cast<studio::CanvasViewUIInterface*>(get_ui_interface().get()),&studio::CanvasViewUIInterface::not_implemented)
154 #define SLOT_EVENT(x) sigc::hide_return(sigc::bind(sigc::mem_fun(*this,&studio::CanvasView::process_event_key),x))
156 /* === C L A S S E S ======================================================= */
159 class studio::UniversalScrubber
161 CanvasView *canvas_view;
164 etl::clock scrub_timer;
166 sigc::connection end_scrub_connection;
168 UniversalScrubber(CanvasView *canvas_view):
169 canvas_view(canvas_view),
172 canvas_view->canvas_interface()->signal_time_changed().connect(
173 sigc::mem_fun(*this,&studio::UniversalScrubber::on_time_changed)
179 end_scrub_connection.disconnect();
182 void on_time_changed()
184 // Make sure we are changing the time quickly
185 // before we enable scrubbing
186 if(!scrubbing && scrub_timer()>1)
192 // If we aren't scrubbing already, enable it
196 audio_container()->start_scrubbing(canvas_view->get_time());
199 // Reset the scrubber ender
200 end_scrub_connection.disconnect();
201 end_scrub_connection=Glib::signal_timeout().connect(
203 sigc::mem_fun(*this,&UniversalScrubber::end_of_scrubbing),
210 audio_container()->scrub(canvas_view->get_time());
215 void end_of_scrubbing()
218 audio_container()->stop_scrubbing();
222 handle<AudioContainer> audio_container()
224 assert(canvas_view->audio);
225 return canvas_view->audio;
230 class studio::CanvasViewUIInterface : public synfigapp::UIInterface
236 CanvasViewUIInterface(CanvasView *view):
240 view->statusbar->push(_("Idle"));
243 ~CanvasViewUIInterface()
245 //view->statusbar->pop();
246 //view->progressbar->set_fraction(0);
249 virtual Response yes_no(const std::string &title, const std::string &message,Response dflt=RESPONSE_YES)
252 //while(studio::App::events_pending())studio::App::iteration(false);
257 true // use_separator
259 Gtk::Label label(message);
262 dialog.get_vbox()->pack_start(label);
263 dialog.add_button(Gtk::StockID("gtk-yes"),RESPONSE_YES);
264 dialog.add_button(Gtk::StockID("gtk-no"),RESPONSE_NO);
266 dialog.set_default_response(dflt);
268 return (Response)dialog.run();
270 virtual Response yes_no_cancel(const std::string &title, const std::string &message,Response dflt=RESPONSE_YES)
273 //while(studio::App::events_pending())studio::App::iteration(false);
278 true // use_separator
280 Gtk::Label label(message);
283 dialog.get_vbox()->pack_start(label);
284 dialog.add_button(Gtk::StockID("gtk-yes"),RESPONSE_YES);
285 dialog.add_button(Gtk::StockID("gtk-no"),RESPONSE_NO);
286 dialog.add_button(Gtk::StockID("gtk-cancel"),RESPONSE_CANCEL);
288 dialog.set_default_response(dflt);
290 return (Response)dialog.run();
292 virtual Response ok_cancel(const std::string &title, const std::string &message,Response dflt=RESPONSE_OK)
295 //while(studio::App::events_pending())studio::App::iteration(false);
300 true // use_separator
302 Gtk::Label label(message);
305 dialog.get_vbox()->pack_start(label);
306 dialog.add_button(Gtk::StockID("gtk-ok"),RESPONSE_OK);
307 dialog.add_button(Gtk::StockID("gtk-cancel"),RESPONSE_CANCEL);
309 dialog.set_default_response(dflt);
311 return (Response)dialog.run();
315 task(const std::string &task)
317 if(!view->is_playing_)
319 view->statusbar->pop();
320 view->statusbar->push(task);
322 //while(studio::App::events_pending())studio::App::iteration(false);
323 if(view->cancel){return false;}
328 error(const std::string &err)
330 view->statusbar->push(_("ERROR"));
332 // If we are in the process of canceling,
333 // then just go ahead and return false --
334 // don't bother displaying a dialog
335 if(view->cancel)return false;
336 Gtk::MessageDialog dialog(*view, err, false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE, true);
339 view->statusbar->pop();
344 warning(const std::string &err)
346 view->statusbar->pop();
347 view->statusbar->push(err);
349 //while(studio::App::events_pending())studio::App::iteration(false);
350 if(view->cancel)return false;
355 amount_complete(int current, int total)
357 if(!view->is_playing_)
359 if(!view->working_depth)
362 view->stopbutton->set_sensitive(true);
364 view->stopbutton->set_sensitive(false);
366 float x((float)current/(float)total);
369 view->progressbar->set_fraction(x);
371 //while(studio::App::events_pending())studio::App::iteration(false);
372 if(view->cancel){/*view->cancel=false;*/return false;}
379 error(_("Feature not yet implemented"));
383 class studio::CanvasViewSelectionManager : public synfigapp::SelectionManager
386 CanvasView::LayerTreeModel layer_tree_model;
387 CanvasView::ChildrenTreeModel children_tree_model;
390 CanvasViewSelectionManager(CanvasView *view): view(view)
397 void _set_selected_layer(const synfig::Layer::Handle &layer)
399 view->layer_tree->select_layer(layer);
401 // Don't change the selection while we are busy
402 // I cannot remember exactly why I put this here...
403 // It musta been for some reason, but I cannot recall.
404 //if(App::Busy::count)
407 if(view->layer_tree->get_selection()->get_selected())
409 const Gtk::TreeRow row = *(view->layer_tree->get_selection()->get_selected());
411 // Don't do anything if that layer is already selected
412 if(layer == static_cast<synfig::Layer::Handle>(row[layer_tree_model.layer]))
415 Gtk::TreeModel::Children::iterator iter;
416 if(view->layer_tree_store()->find_layer_row(layer,iter))
418 Gtk::TreePath path(iter);
419 for(int i=path.get_depth();i;i--)
422 path=Gtk::TreePath(iter);
425 view->layer_tree->get_tree_view().expand_row(path,false);
427 view->layer_tree->get_tree_view().scroll_to_row(Gtk::TreePath(iter));
428 view->layer_tree->get_selection()->select(iter);
434 //! Returns the number of layers selected.
435 virtual int get_selected_layer_count()const
437 return get_selected_layers().size();
440 //! Returns a list of the currently selected layers.
441 virtual LayerList get_selected_layers()const
443 // assert(view->layer_tree);
445 if(!view->layer_tree) { synfig::error("%s:%d canvas_view.layer_tree not defined!?", __FILE__, __LINE__); return LayerList(); }
446 return view->layer_tree->get_selected_layers();
449 //! Returns the first layer selected or an empty handle if none are selected.
450 virtual synfig::Layer::Handle get_selected_layer()const
452 // assert(view->layer_tree);
454 if(!view->layer_tree) { synfig::error("%s:%d canvas_view.layer_tree not defined!?", __FILE__, __LINE__); return 0; }
455 return view->layer_tree->get_selected_layer();
458 //! Sets which layers should be selected
459 virtual void set_selected_layers(const LayerList &layer_list)
461 // assert(view->layer_tree);
463 if(!view->layer_tree) { synfig::error("%s:%d canvas_view.layer_tree not defined!?", __FILE__, __LINE__); return; }
464 view->layer_tree->select_layers(layer_list);
465 //view->get_smach().process_event(EVENT_REFRESH_DUCKS);
467 //view->queue_rebuild_ducks();
470 //! Sets which layer should be selected.
471 virtual void set_selected_layer(const synfig::Layer::Handle &layer)
473 // assert(view->layer_tree);
475 if(!view->layer_tree) { synfig::error("canvas_view.layer_tree not defined!?"); return; }
476 view->layer_tree->select_layer(layer);
477 //view->queue_rebuild_ducks();
480 //! Clears the layer selection list
481 virtual void clear_selected_layers()
483 if(!view->layer_tree) return;
484 view->layer_tree->clear_selected_layers();
489 //! Returns the number of value_nodes selected.
490 virtual int get_selected_children_count()const
492 return get_selected_children().size();
495 static inline void __child_grabber(const Gtk::TreeModel::iterator& iter, ChildrenList* ret)
497 const CanvasView::ChildrenTreeModel children_tree_model;
498 synfigapp::ValueDesc value_desc((*iter)[children_tree_model.value_desc]);
500 ret->push_back(value_desc);
503 //! Returns a list of the currently selected value_nodes.
504 virtual ChildrenList get_selected_children()const
506 if(!view->children_tree) return ChildrenList();
508 Glib::RefPtr<Gtk::TreeSelection> selection=view->children_tree->get_selection();
511 return ChildrenList();
515 selection->selected_foreach_iter(
518 &studio::CanvasViewSelectionManager::__child_grabber
525 Gtk::TreeModel::Children::iterator iter(view->children_tree_store()->children().begin());
527 Gtk::TreeModel::Children children = iter->children();
528 for(iter = children.begin(); iter != children.end(); ++iter)
530 Gtk::TreeModel::Row row = *iter;
531 if(selection->is_selected(row))
532 ret.push_back((synfigapp::ValueDesc)row[children_tree_model.value_desc]);
538 //! Returns the first value_node selected or an empty handle if none are selected.
539 virtual ChildrenList::value_type get_selected_child()const
541 if(!view->children_tree) return ChildrenList::value_type();
543 ChildrenList children(get_selected_children());
546 return ChildrenList::value_type();
548 return children.front();
551 //! Sets which value_nodes should be selected
552 virtual void set_selected_children(const ChildrenList &/*children_list*/)
557 //! Sets which value_node should be selected. Empty handle if none.
558 virtual void set_selected_child(const ChildrenList::value_type &/*child*/)
563 //! Clears the value_node selection list
564 virtual void clear_selected_children()
571 int get_selected_layer_parameter_count()const
573 return get_selected_layer_parameters().size();
576 LayerParamList get_selected_layer_parameters()const
578 if(!view->layer_tree) return LayerParamList();
580 Glib::RefPtr<Gtk::TreeSelection> selection=view->layer_tree->get_selection();
583 return LayerParamList();
587 Gtk::TreeModel::Children children = const_cast<CanvasView*>(view)->layer_tree_store()->children();
588 Gtk::TreeModel::Children::iterator iter;
589 for(iter = children.begin(); iter != children.end(); ++iter)
591 Gtk::TreeModel::Row row = *iter;
592 Gtk::TreeModel::Children::iterator iter;
593 for(iter=row.children().begin();iter!=row.children().end();iter++)
595 Gtk::TreeModel::Row row = *iter;
596 if(selection->is_selected(row))
597 ret.push_back(LayerParam(row[layer_tree_model.layer],(Glib::ustring)row[layer_tree_model.id]));
603 LayerParam get_selected_layer_parameter() const
605 if(!view->layer_tree) return LayerParam();
606 return get_selected_layer_parameters().front();
609 void set_selected_layer_parameters(const LayerParamList &/*layer_param_list*/)
614 void set_selected_layer_param(const LayerParam &/*layer_param*/)
619 void clear_selected_layer_parameters()
624 }; // END of class SelectionManager
627 CanvasView::IsWorking::IsWorking(CanvasView &canvas_view_):
628 canvas_view_(canvas_view_)
630 if(!canvas_view_.working_depth)
631 canvas_view_.stopbutton->set_sensitive(true);
632 canvas_view_.working_depth++;
633 canvas_view_.cancel=false;
636 CanvasView::IsWorking::~IsWorking()
638 canvas_view_.working_depth--;
639 if(!canvas_view_.working_depth)
640 canvas_view_.stopbutton->set_sensitive(false);
643 CanvasView::IsWorking::operator bool()const
645 if(canvas_view_.cancel)
650 /* === M E T H O D S ======================================================= */
652 CanvasView::CanvasView(etl::loose_handle<Instance> instance,etl::handle<synfigapp::CanvasInterface> canvas_interface_):
654 instance_ (instance),
655 canvas_interface_ (canvas_interface_),
656 //layer_tree_store_ (LayerTreeStore::create(canvas_interface_)),
657 //children_tree_store_ (ChildrenTreeStore::create(canvas_interface_)),
658 //keyframe_tree_store_ (KeyframeTreeStore::create(canvas_interface_)),
659 time_adjustment_ (0,0,25,0,0,0),
660 time_window_adjustment_ (0,0,25,0,0,0),
661 statusbar (manage(new class Gtk::Statusbar())),
663 timeslider (new Widget_Timeslider),
665 ui_interface_ (new CanvasViewUIInterface(this)),
666 selection_manager_ (new CanvasViewSelectionManager(this)),
672 canvas_properties (*this,canvas_interface_),
673 canvas_options (this),
674 render_settings (*this,canvas_interface_),
675 waypoint_dialog (*this,canvas_interface_->get_canvas()),
676 keyframe_dialog (*this,canvas_interface_),
677 preview_dialog (new Dialog_Preview),
678 sound_dialog (new Dialog_SoundSelect(*this,canvas_interface_))
682 duck_refresh_flag=true;
684 smach_.set_default_state(&state_normal);
686 disp_audio = new Widget_Sound();
688 //synfig::info("Canvasview: Entered constructor");
690 get_canvas()->set_time(0);
691 //layer_tree_store_->rebuild();
693 // Set up the UI and Selection managers
694 canvas_interface()->set_ui_interface(get_ui_interface());
695 canvas_interface()->set_selection_manager(get_selection_manager());
696 rebuild_ducks_queued=false;
698 //notebook=manage(new class Gtk::Notebook());
699 //Gtk::VPaned *vpaned = manage(new class Gtk::VPaned());
700 //vpaned->pack1(*create_work_area(), Gtk::EXPAND|Gtk::SHRINK);
701 //vpaned->pack2(*notebook, Gtk::SHRINK);
702 //vpaned->show_all();
707 //notebook->append_page(*create_layer_tree(),_("Layers"));
708 //notebook->append_page(*create_children_tree(),_("Children"));
709 //notebook->append_page(*create_keyframe_tree(),_("Keyframes"));
711 //synfig::info("Canvasview: Before big chunk of allocation and tabling stuff");
712 //create all allocated stuff for this canvas
713 audio = new AudioContainer();
715 Gtk::Table *layout_table= manage(new class Gtk::Table(1, 3, false));
716 //layout_table->attach(*vpaned, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
717 layout_table->attach(*create_work_area(), 0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
719 //layout_table->attach(*App::ui_manager()->get_widget("/menu-main"), 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
722 layout_table->attach(*create_time_bar(), 0, 1, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
723 layout_table->attach(*create_status_bar(), 0, 1, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
727 layout_table->show();
730 //set_transient_for(*App::toolbox);
732 //synfig::info("Canvasview: Before Signals");
734 -- ** -- Signals -------------------------------------------------------------
737 canvas_interface()->signal_dirty_preview().connect(sigc::mem_fun(*this,&studio::CanvasView::on_dirty_preview));
738 canvas_interface()->signal_mode_changed().connect(sigc::mem_fun(*this,&studio::CanvasView::on_mode_changed));
740 canvas_interface()->signal_time_changed().connect(sigc::mem_fun(*this,&studio::CanvasView::on_time_changed));
742 //canvas_interface()->signal_time_changed().connect(sigc::mem_fun(*this,&studio::CanvasView::refresh_tables));
743 canvas_interface()->signal_id_changed().connect(sigc::mem_fun(*this,&studio::CanvasView::on_id_changed));
744 canvas_interface()->signal_rend_desc_changed().connect(sigc::mem_fun(*this,&studio::CanvasView::refresh_rend_desc));
745 waypoint_dialog.signal_changed().connect(sigc::mem_fun(*this,&studio::CanvasView::on_waypoint_changed));
746 waypoint_dialog.signal_delete().connect(sigc::mem_fun(*this,&studio::CanvasView::on_waypoint_delete));
748 //MODIFIED TIME ADJUSTMENT STUFF....
749 time_window_adjustment().set_child_adjustment(&time_adjustment());
750 time_window_adjustment().signal_value_changed().connect(sigc::mem_fun(*this,&studio::CanvasView::refresh_time_window));
751 time_adjustment().signal_value_changed().connect(sigc::mem_fun(*this,&studio::CanvasView::time_was_changed));
754 work_area->signal_layer_selected().connect(sigc::mem_fun(*this,&studio::CanvasView::workarea_layer_selected));
755 work_area->signal_input_device_changed().connect(sigc::mem_fun(*this,&studio::CanvasView::on_input_device_changed));
757 canvas_interface()->signal_canvas_added().connect(
759 sigc::mem_fun(*instance,&studio::Instance::refresh_canvas_tree)
762 canvas_interface()->signal_canvas_removed().connect(
764 sigc::mem_fun(*instance,&studio::Instance::refresh_canvas_tree)
768 canvas_interface()->signal_layer_param_changed().connect(
771 SLOT_EVENT(EVENT_REFRESH_DUCKS)
777 //MUCH TIME STUFF TAKES PLACE IN HERE
779 refresh_time_window();
781 /*! \todo We shouldn't need to do this at construction --
782 ** This should be performed at the first time the window
785 work_area->queue_render_preview();
787 // If the canvas is really big, zoom out so that we can fit it all in the window
788 /*! \todo In other words, this is a zoom-to-fit, and should be
789 ** in its own function.
791 int w=get_canvas()->rend_desc().get_w()+70;
792 int h=get_canvas()->rend_desc().get_h()+70;
793 while(w>700 || h>600)
797 // WorkArea::async_update_preview() =>
798 // WorkArea::set_zoom(float) =>
799 // WorkArea::async_update_preview() =>
800 // desc.set_time(cur_time), where cur_time isn't initialized
801 work_area->set_time(0);
802 work_area->zoom_out();
803 w=round_to_int(get_canvas()->rend_desc().get_w()*work_area->get_zoom()+70);
804 h=round_to_int(get_canvas()->rend_desc().get_h()*work_area->get_zoom()+70);
808 set_default_size(w,h);
809 property_window_position().set_value(Gtk::WIN_POS_NONE);
814 std::list<Gtk::TargetEntry> listTargets;
815 listTargets.push_back( Gtk::TargetEntry("STRING") );
816 listTargets.push_back( Gtk::TargetEntry("text/plain") );
817 listTargets.push_back( Gtk::TargetEntry("image") );
819 drag_dest_set(listTargets);
820 signal_drag_data_received().connect( sigc::mem_fun(*this, &studio::CanvasView::on_drop_drag_data_received) );
824 Time length(get_canvas()->rend_desc().get_time_end()-get_canvas()->rend_desc().get_time_start());
827 time_window_adjustment().set_page_increment(length);
828 time_window_adjustment().set_page_size(length);
832 time_window_adjustment().set_page_increment(10.0);
833 time_window_adjustment().set_page_size(10.0);
837 //synfig::info("Canvasview: Before Sound Hookup");
838 //load sound info from meta data
840 //synfig::warning("Should load Audio: %s with %s offset",apath.c_str(),aoffset.c_str());
842 on_audio_file_notify(); //redundant setting of the metadata, but oh well, it's no big deal :)
843 on_audio_offset_notify();
845 //signal connection - since they are all associated with the canvas view
847 //hook in signals for sound options box
848 sound_dialog->signal_file_changed().connect(sigc::mem_fun(*this,&CanvasView::on_audio_file_change));
849 sound_dialog->signal_offset_changed().connect(sigc::mem_fun(*this,&CanvasView::on_audio_offset_change));
851 //attach to the preview when it's visible
852 //preview_dialog->get_widget().signal_play().connect(sigc::mem_fun(*this,&CanvasView::play_audio));
853 //preview_dialog->get_widget().signal_stop().connect(sigc::mem_fun(*this,&CanvasView::stop_audio));
855 //hook to metadata signals
856 get_canvas()->signal_meta_data_changed("audiofile").connect(sigc::mem_fun(*this,&CanvasView::on_audio_file_notify));
857 get_canvas()->signal_meta_data_changed("audiooffset").connect(sigc::mem_fun(*this,&CanvasView::on_audio_offset_notify));
859 //universal_scrubber=std::auto_ptr<UniversalScrubber>(new UniversalScrubber(this));
862 //synfig::info("Canvasview: Before Final time set up");
864 time_window_adjustment().set_value(get_canvas()->rend_desc().get_time_start());
865 time_window_adjustment().value_changed();
868 GRAB_HINT_DATA("canvas_view");
871 set_skip_taskbar_hint(true);
872 set_skip_pager_hint(true);
873 set_type_hint(Gdk::WINDOW_TYPE_HINT_UTILITY);
881 //synfig::info("Canvasview: Constructor Done");
884 CanvasView::~CanvasView()
888 App::ui_manager()->remove_action_group(action_group);
890 // Shut down the smach
892 smach_.set_default_state(0);
894 // We want to ensure that the UI_Manager and
895 // the selection manager get destructed right now.
896 ui_interface_.reset();
897 selection_manager_.reset();
899 // Delete any external widgets
900 for(;!ext_widget_book_.empty();ext_widget_book_.erase(ext_widget_book_.begin()))
902 if(ext_widget_book_.begin()->second)
903 delete ext_widget_book_.begin()->second;
911 // don't be calling on_dirty_preview once this object has been deleted;
912 // this was causing a crash before
913 canvas_interface()->signal_dirty_preview().clear();
915 if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
916 synfig::info("CanvasView::~CanvasView(): Deleted");
922 CanvasView::get_pixel_sizes()
924 // prime factors of 120 are 2, 2, 2, 3, 5 - see TILE_SIZE in synfig-core/trunk/src/synfig/target_tile.h
925 static int pixel_size_array[] = {2,3,4,5,6,8,10,12,15,20,24,30,40,60,120};
926 static list<int> pixel_sizes = list<int>(pixel_size_array, pixel_size_array + sizeof(pixel_size_array) / sizeof(int));
932 CanvasView::create_time_bar()
936 Gtk::HScrollbar *time_window_scroll = manage(new class Gtk::HScrollbar(time_window_adjustment()));
937 //Gtk::HScrollbar *time_scroll = manage(new class Gtk::HScrollbar(time_adjustment()));
938 //TIME BAR TEMPORARY POSITION
939 //Widget_Timeslider *time_scroll = manage(new Widget_Timeslider);
941 timeslider->set_time_adjustment(&time_adjustment());
942 timeslider->set_bounds_adjustment(&time_window_adjustment());
943 //layout_table->attach(*timeslider, 0, 1, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL);
946 tooltips.set_tip(*time_window_scroll,_("Moves the time window"));
947 tooltips.set_tip(*timeslider,_("Changes the current time"));
948 time_window_scroll->show();
950 time_window_scroll->set_flags(Gtk::CAN_FOCUS);
951 timeslider->set_flags(Gtk::CAN_FOCUS);
953 //time_scroll->signal_value_changed().connect(sigc::mem_fun(*work_area, &studio::WorkArea::render_preview_hook));
954 //time_scroll->set_update_policy(Gtk::UPDATE_DISCONTINUOUS);
956 NORMAL_BUTTON(animatebutton,"gtk-yes",_("Animate"));
957 animatebutton->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasView::on_animate_button_pressed));
958 animatebutton->show();
960 NORMAL_BUTTON(keyframebutton,"synfig-keyframe_lock_all",_("All Keyframes Locked"));
961 keyframebutton->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasView::on_keyframe_button_pressed));
962 keyframebutton->show();
964 Gtk::Table *table= manage(new class Gtk::Table(2, 3, false));
966 //setup the audio display
967 disp_audio->set_size_request(-1,32); //disp_audio->show();
968 disp_audio->set_time_adjustment(&time_adjustment());
969 disp_audio->signal_start_scrubbing().connect(
970 sigc::mem_fun(*audio,&AudioContainer::start_scrubbing)
972 disp_audio->signal_scrub().connect(
973 sigc::mem_fun(*audio,&AudioContainer::scrub)
975 disp_audio->signal_stop_scrubbing().connect(
976 sigc::mem_fun(*audio,&AudioContainer::stop_scrubbing)
979 table->attach(*manage(disp_audio), 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
980 table->attach(*timeslider, 0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK, 0, 0);
981 table->attach(*time_window_scroll, 0, 1, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK, 0, 0);
983 table->attach(*animatebutton, 1, 2, 0, 3, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
984 table->attach(*keyframebutton, 2, 3, 0, 3, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
991 CanvasView::create_work_area()
993 work_area=std::auto_ptr<WorkArea>(new class studio::WorkArea(canvas_interface_));
994 work_area->set_instance(get_instance());
995 work_area->set_canvas(get_canvas());
996 work_area->set_canvas_view(this);
997 work_area->set_progress_callback(get_ui_interface().get());
998 work_area->signal_popup_menu().connect(sigc::mem_fun(*this, &studio::CanvasView::popup_main_menu));
1000 return work_area.get();
1005 CanvasView::create_status_bar()
1008 Gtk::IconSize iconsize=Gtk::IconSize::from_name("synfig-small_icon");
1011 // Create the status bar at the bottom of the window
1012 Gtk::Table *statusbartable= manage(new class Gtk::Table(7, 1, false));
1013 // statusbar = manage(new class Gtk::Statusbar()); // This is already done at construction
1014 progressbar =manage(new class Gtk::ProgressBar());
1015 SMALL_BUTTON(stopbutton,"gtk-stop",_("Stop"));
1016 SMALL_BUTTON(refreshbutton,"gtk-refresh",_("Refresh"));
1017 //SMALL_BUTTON(treetogglebutton,"gtk-go-down",_("Toggle Layer Tree"));
1018 // NEW_SMALL_BUTTON(raisebutton,"gtk-go-up",_("Raise Layer"));
1019 // NEW_SMALL_BUTTON(lowerbutton,"gtk-go-down",_("Lower Layer"));
1020 //statusbartable->attach(*treetogglebutton, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
1021 // statusbartable->attach(*lowerbutton, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
1022 // statusbartable->attach(*raisebutton, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
1025 current_time_widget=manage(new Widget_Time);
1026 current_time_widget->set_value(get_time());
1027 current_time_widget->set_fps(get_canvas()->rend_desc().get_frame_rate());
1028 current_time_widget->signal_value_changed().connect(
1029 sigc::mem_fun(*this,&CanvasView::on_current_time_widget_changed)
1032 statusbartable->attach(*current_time_widget, 0, 1, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
1033 statusbartable->attach(*statusbar, 3, 4, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
1034 statusbartable->attach(*progressbar, 4, 5, 0, 1, Gtk::SHRINK, Gtk::EXPAND|Gtk::FILL, 0, 0);
1035 statusbartable->attach(*refreshbutton, 5, 6, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
1036 statusbartable->attach(*stopbutton, 6, 7, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
1037 statusbar->set_has_resize_grip(false);
1040 refreshbutton->show();
1041 progressbar->show();
1042 stopbutton->set_sensitive(false);
1044 //refreshbutton->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasView::on_refresh_pressed));
1045 //stopbutton->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasView::stop));
1046 //treetogglebutton->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasView::toggle_tables));
1048 refreshbutton->signal_clicked().connect(SLOT_EVENT(EVENT_REFRESH));
1049 stopbutton->signal_clicked().connect(SLOT_EVENT(EVENT_STOP));
1052 statusbartable->show_all();
1053 return statusbartable;
1057 CanvasView::on_current_time_widget_changed()
1059 set_time(current_time_widget->get_value());
1063 // CanvasView::create_children_tree()
1065 // // Create the layer tree
1066 // children_tree=manage(new class ChildrenTree());
1068 // // Set up the layer tree
1069 // //children_tree->set_model(children_tree_store());
1070 // if(children_tree)children_tree->set_time_adjustment(time_adjustment());
1071 // if(children_tree)children_tree->show();
1073 // // Connect Signals
1074 // if(children_tree)children_tree->signal_edited_value().connect(sigc::mem_fun(*this, &studio::CanvasView::on_edited_value));
1075 // if(children_tree)children_tree->signal_user_click().connect(sigc::mem_fun(*this, &studio::CanvasView::on_children_user_click));
1076 // if(children_tree)children_tree->signal_waypoint_clicked().connect(sigc::mem_fun(*this, &studio::CanvasView::on_waypoint_clicked));
1077 // if(children_tree)children_tree->get_selection()->signal_changed().connect(SLOT_EVENT(EVENT_REFRESH_DUCKS));
1079 // return children_tree;
1083 // CanvasView::create_keyframe_tree()
1085 // keyframe_tree=manage(new KeyframeTree());
1087 // //keyframe_tree->get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);
1088 // //keyframe_tree->show();
1089 // //keyframe_tree->set_model(keyframe_tree_store());
1090 // keyframe_tree->set_editable(true);
1091 // //keyframe_tree->signal_edited().connect(sigc::hide_return(sigc::mem_fun(*canvas_interface(), &synfigapp::CanvasInterface::update_keyframe)));
1093 // keyframe_tree->signal_event().connect(sigc::mem_fun(*this, &studio::CanvasView::on_keyframe_tree_event));
1095 // Gtk::ScrolledWindow *scroll_layer_tree = manage(new class Gtk::ScrolledWindow());
1096 // scroll_layer_tree->set_flags(Gtk::CAN_FOCUS);
1097 // scroll_layer_tree->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
1098 // scroll_layer_tree->add(*keyframe_tree);
1099 // scroll_layer_tree->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
1100 // //scroll_layer_tree->show();
1103 // Gtk::Table *layout_table= manage(new Gtk::Table(1, 2, false));
1104 // layout_table->attach(*scroll_layer_tree, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
1106 // Gtk::Image *icon;
1107 // Gtk::IconSize iconsize(Gtk::IconSize::from_name("synfig-small_icon"));
1109 // NEW_SMALL_BUTTON(button_add,"gtk-add",_("New Keyframe"));
1110 // NEW_SMALL_BUTTON(button_duplicate,"synfig-duplicate",_("Duplicate Keyframe"));
1111 // NEW_SMALL_BUTTON(button_delete,"gtk-delete",_("Delete Keyframe"));
1113 // Gtk::HBox *hbox(manage(new Gtk::HBox()));
1114 // layout_table->attach(*hbox, 0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK, 0, 0);
1116 // hbox->pack_start(*button_add,Gtk::PACK_SHRINK);
1117 // hbox->pack_start(*button_duplicate,Gtk::PACK_SHRINK);
1118 // hbox->pack_start(*button_delete,Gtk::PACK_SHRINK);
1121 // button_raise->set_relief(Gtk::RELIEF_HALF);
1122 // button_lower->set_relief(Gtk::RELIEF_HALF);
1123 // button_duplicate->set_relief(Gtk::RELIEF_HALF);
1124 // button_delete->set_relief(Gtk::RELIEF_HALF);
1127 // button_add->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasView::on_keyframe_add_pressed));
1128 // button_duplicate->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasView::on_keyframe_duplicate_pressed));
1129 // button_delete->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasView::on_keyframe_remove_pressed));
1131 // //layout_table->show_all();
1133 // keyframe_tab_child=layout_table;
1136 // layout_table->hide();
1138 // return layout_table;
1142 // CanvasView::create_layer_tree()
1144 // // Create the layer tree
1145 // printf("CanvasView::create_layer_tree()\n");
1146 // layer_tree=manage(new class LayerTree());
1148 // // Set up the layer tree
1149 // //layer_tree->set_model(layer_tree_store());
1150 // layer_tree->set_time_adjustment(time_adjustment());
1151 // layer_tree->show();
1153 // // Connect Signals
1154 // layer_tree->signal_layer_toggle().connect(sigc::mem_fun(*this, &studio::CanvasView::on_layer_toggle));
1155 // layer_tree->signal_edited_value().connect(sigc::mem_fun(*this, &studio::CanvasView::on_edited_value));
1156 // layer_tree->signal_layer_user_click().connect(sigc::mem_fun(*this, &studio::CanvasView::on_layer_user_click));
1157 // layer_tree->signal_param_user_click().connect(sigc::mem_fun(*this, &studio::CanvasView::on_children_user_click));
1158 // layer_tree->signal_waypoint_clicked().connect(sigc::mem_fun(*this, &studio::CanvasView::on_waypoint_clicked));
1159 // layer_tree->get_selection()->signal_changed().connect(SLOT_EVENT(EVENT_REFRESH_DUCKS));
1161 // layer_tree->hide();
1162 // return layer_tree;
1166 CanvasView::init_menus()
1169 mainmenu.set_accel_group(get_accel_group());
1170 mainmenu.set_accel_path("<Canvas-view>");
1172 filemenu.set_accel_group(get_accel_group());
1173 filemenu.set_accel_path("<Canvas-view>/File");
1175 editmenu.set_accel_group(get_accel_group());
1176 editmenu.set_accel_path("<Canvas-view>/Edit");
1178 layermenu.set_accel_group(get_accel_group());
1179 layermenu.set_accel_path("<Canvas-view>/Layer");
1181 //cache the position of desired widgets
1183 /*Menus to worry about:
1192 action_group = Gtk::ActionGroup::create();
1194 //action_group->add( Gtk::Action::create("MenuFile", _("_File")) );
1195 action_group->add( Gtk::Action::create("new", Gtk::Stock::NEW),
1196 sigc::hide_return(sigc::ptr_fun(&studio::App::new_instance))
1198 action_group->add( Gtk::Action::create("open", Gtk::Stock::OPEN),
1199 sigc::hide_return(sigc::ptr_fun(&studio::App::dialog_open))
1201 action_group->add( Gtk::Action::create("save", Gtk::Stock::SAVE),
1202 hide_return(sigc::mem_fun(*get_instance().get(), &studio::Instance::save))
1204 action_group->add( Gtk::Action::create("save-as", Gtk::Stock::SAVE_AS),
1205 sigc::hide_return(sigc::mem_fun(*get_instance().get(), &studio::Instance::dialog_save_as))
1207 action_group->add( Gtk::Action::create("revert", Gtk::Stock::REVERT_TO_SAVED),
1208 sigc::hide_return(sigc::mem_fun(*get_instance().get(), &studio::Instance::safe_revert))
1210 action_group->add( Gtk::Action::create("cvs-add", Gtk::StockID("synfig-cvs_add")),
1211 sigc::hide_return(sigc::mem_fun(*get_instance(), &studio::Instance::dialog_cvs_add))
1213 action_group->add( Gtk::Action::create("cvs-update", Gtk::StockID("synfig-cvs_update")),
1214 sigc::hide_return(sigc::mem_fun(*get_instance(), &studio::Instance::dialog_cvs_update))
1216 action_group->add( Gtk::Action::create("cvs-revert", Gtk::StockID("synfig-cvs_revert")),
1217 sigc::hide_return(sigc::mem_fun(*get_instance(), &studio::Instance::dialog_cvs_revert))
1219 action_group->add( Gtk::Action::create("cvs-commit", Gtk::StockID("synfig-cvs_commit")),
1220 sigc::hide_return(sigc::mem_fun(*get_instance(), &studio::Instance::dialog_cvs_commit))
1222 action_group->add( Gtk::Action::create("import", _("Import")),
1223 sigc::hide_return(sigc::mem_fun(*this, &studio::CanvasView::image_import))
1225 action_group->add( Gtk::Action::create("render", _("Render")),
1226 sigc::mem_fun0(render_settings,&studio::RenderSettings::present)
1228 action_group->add( Gtk::Action::create("preview", _("Preview")),
1229 sigc::mem_fun(*this,&CanvasView::on_preview_option)
1231 action_group->add( Gtk::Action::create("sound", _("Sound File")),
1232 sigc::mem_fun(*this,&CanvasView::on_audio_option)
1234 action_group->add( Gtk::Action::create("options", _("Options")),
1235 sigc::mem_fun0(canvas_options,&studio::CanvasOptions::present)
1237 action_group->add( Gtk::Action::create("close", Gtk::StockID("gtk-close"), _("Close Window")),
1238 sigc::hide_return(sigc::mem_fun(*this,&studio::CanvasView::close_view))
1240 action_group->add( Gtk::Action::create("close-document", Gtk::StockID("gtk-close"), _("Close Document")),
1241 sigc::hide_return(sigc::mem_fun(*this,&studio::CanvasView::close_instance))
1243 action_group->add( Gtk::Action::create("quit", Gtk::StockID("gtk-quit"), _("Quit")),
1244 sigc::hide_return(sigc::ptr_fun(&studio::App::quit))
1247 //action_group->add( Gtk::Action::create("undo", Gtk::StockID("gtk-undo")),
1248 // SLOT_EVENT(EVENT_UNDO)
1251 //action_group->add( Gtk::Action::create("redo", Gtk::StockID("gtk-redo")),
1252 // SLOT_EVENT(EVENT_REDO)
1255 action_group->add( Gtk::Action::create("select-all-ducks", _("Select All Ducks")),
1256 sigc::mem_fun(*work_area,&studio::WorkArea::select_all_ducks)
1259 action_group->add( Gtk::Action::create("unselect-all-layers", _("Unselect All Layers")),
1260 sigc::mem_fun(*this,&CanvasView::on_unselect_layers)
1263 action_group->add( Gtk::Action::create("stop", Gtk::StockID("gtk-stop")),
1264 SLOT_EVENT(EVENT_STOP)
1267 action_group->add( Gtk::Action::create("refresh", Gtk::StockID("gtk-refresh")),
1268 SLOT_EVENT(EVENT_REFRESH)
1271 action_group->add( Gtk::Action::create("properties", Gtk::StockID("gtk-properties")),
1272 sigc::mem_fun0(canvas_properties,&studio::CanvasProperties::present)
1275 // Preview Quality Menu
1278 action_group->add( Gtk::RadioAction::create(quality_group,"quality-00", _("Use Parametric Renderer")),
1280 sigc::mem_fun(*work_area, &studio::WorkArea::set_quality),
1287 if (i == 1) note = _(" (best)");
1288 if (i == 10) note = _(" (fastest)");
1289 Glib::RefPtr<Gtk::RadioAction> action(Gtk::RadioAction::create(quality_group,strprintf("quality-%02d",i),
1290 strprintf(_("Set Quality to %d"),i) + note));
1291 if(i==9) // default quality
1293 action->set_active();
1294 work_area->set_quality(i);
1296 action_group->add( action,
1298 sigc::mem_fun(*work_area, &studio::WorkArea::set_quality),
1305 // Low-Res Quality Menu
1308 for(list<int>::iterator iter = CanvasView::get_pixel_sizes().begin(); iter != CanvasView::get_pixel_sizes().end(); iter++)
1311 Glib::RefPtr<Gtk::RadioAction> action(Gtk::RadioAction::create(low_res_pixel_size_group,strprintf("lowres-pixel-%d",i),
1312 strprintf(_("Set Low-Res pixel size to %d"),i)));
1313 if(i==2) // default pixel size
1315 action->set_active();
1316 work_area->set_low_res_pixel_size(i);
1318 action_group->add( action,
1320 sigc::mem_fun(*work_area, &studio::WorkArea::set_low_res_pixel_size),
1326 Glib::RefPtr<Gtk::Action> action;
1328 action=Gtk::Action::create("decrease-low-res-pixel-size", _("Decrease Low-Res Pixel Size"));
1329 action_group->add( action,sigc::mem_fun(this, &studio::CanvasView::decrease_low_res_pixel_size));
1331 action=Gtk::Action::create("increase-low-res-pixel-size", _("Increase Low-Res Pixel Size"));
1332 action_group->add( action, sigc::mem_fun(this, &studio::CanvasView::increase_low_res_pixel_size));
1336 action_group->add( Gtk::Action::create("play", Gtk::Stock::MEDIA_PLAY),
1337 sigc::mem_fun(*this, &studio::CanvasView::play)
1340 action_group->add( Gtk::Action::create("dialog-flipbook", _("Flipbook Dialog")),
1341 sigc::mem_fun0(*preview_dialog, &studio::Dialog_Preview::present)
1345 Glib::RefPtr<Gtk::ToggleAction> action;
1347 action = Gtk::ToggleAction::create("toggle-grid-show", _("Show Grid"));
1348 action->set_active(work_area->grid_status());
1349 action_group->add(action, sigc::mem_fun(*work_area, &studio::WorkArea::toggle_grid));
1351 action = Gtk::ToggleAction::create("toggle-grid-snap", _("Snap to Grid"));
1352 action->set_active(work_area->get_grid_snap());
1353 action_group->add(action, sigc::mem_fun(*work_area, &studio::WorkArea::toggle_grid_snap));
1355 action = Gtk::ToggleAction::create("toggle-guide-show", _("Show Guides"));
1356 action->set_active(work_area->get_show_guides());
1357 action_group->add(action, sigc::mem_fun(*work_area, &studio::WorkArea::toggle_guide_snap));
1359 action = Gtk::ToggleAction::create("toggle-low-res", _("Use Low-Res"));
1360 action->set_active(work_area->get_low_resolution_flag());
1361 action_group->add(action, sigc::mem_fun(*work_area, &studio::WorkArea::toggle_low_resolution_flag));
1363 action = Gtk::ToggleAction::create("toggle-onion-skin", _("Show Onion Skin"));
1364 action->set_active(work_area->get_onion_skin());
1365 action_group->add(action, sigc::mem_fun(*work_area, &studio::WorkArea::toggle_onion_skin));
1368 action_group->add( Gtk::Action::create("canvas-zoom-fit", Gtk::StockID("gtk-zoom-fit")),
1369 sigc::mem_fun(*work_area, &studio::WorkArea::zoom_fit)
1371 action_group->add( Gtk::Action::create("canvas-zoom-100", Gtk::StockID("gtk-zoom-100")),
1372 sigc::mem_fun(*work_area, &studio::WorkArea::zoom_norm)
1376 Glib::RefPtr<Gtk::Action> action;
1378 action=Gtk::Action::create("seek-next-frame", Gtk::Stock::GO_FORWARD,_("Next Frame"),_("Next Frame"));
1379 action_group->add(action,sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek_frame),1));
1380 action=Gtk::Action::create("seek-prev-frame", Gtk::Stock::GO_BACK,_("Prev Frame"),_("Prev Frame"));
1381 action_group->add( action, sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek_frame),-1));
1383 action=Gtk::Action::create("seek-next-second", Gtk::Stock::GO_FORWARD,_("Seek Forward"),_("Seek Forward"));
1384 action_group->add(action,sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek_time),Time(1)));
1385 action=Gtk::Action::create("seek-prev-second", Gtk::Stock::GO_BACK,_("Seek Backward"),_("Seek Backward"));
1386 action_group->add( action, sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek_time),Time(-1)));
1388 action=Gtk::Action::create("seek-end", Gtk::Stock::GOTO_LAST,_("Seek to End"),_("Seek to End"));
1389 action_group->add(action,sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek_time),Time::end()));
1391 action=Gtk::Action::create("seek-begin", Gtk::Stock::GOTO_FIRST,_("Seek to Begin"),_("Seek to Begin"));
1392 action_group->add( action, sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek_time),Time::begin()));
1394 action=Gtk::Action::create("jump-next-keyframe", Gtk::Stock::GO_FORWARD,_("Jump to Next Keyframe"),_("Jump to Next Keyframe"));
1395 action_group->add( action,sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::jump_to_next_keyframe));
1397 action=Gtk::Action::create("jump-prev-keyframe", Gtk::Stock::GO_BACK,_("Jump to Prev Keyframe"),_("Jump to Prev Keyframe"));
1398 action_group->add( action,sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::jump_to_prev_keyframe));
1400 action=Gtk::Action::create("canvas-zoom-in", Gtk::Stock::ZOOM_IN);
1401 action_group->add( action,sigc::mem_fun(*work_area, &studio::WorkArea::zoom_in));
1403 action=Gtk::Action::create("canvas-zoom-out", Gtk::Stock::ZOOM_OUT);
1404 action_group->add( action, sigc::mem_fun(*work_area, &studio::WorkArea::zoom_out) );
1406 action=Gtk::Action::create("time-zoom-in", Gtk::Stock::ZOOM_IN, _("Zoom In on Timeline"));
1407 action_group->add( action, sigc::mem_fun(*this, &studio::CanvasView::time_zoom_in) );
1409 action=Gtk::Action::create("time-zoom-out", Gtk::Stock::ZOOM_OUT, _("Zoom Out on Timeline"));
1410 action_group->add( action, sigc::mem_fun(*this, &studio::CanvasView::time_zoom_out) );
1415 #define DUCK_MASK(lower,upper,string) \
1416 duck_mask_##lower=Gtk::ToggleAction::create("mask-" #lower "-ducks", string); \
1417 duck_mask_##lower->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_##upper)); \
1418 action_group->add( duck_mask_##lower, \
1420 sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask), \
1421 Duck::TYPE_##upper \
1424 DUCK_MASK(position,POSITION,_("Show Position Ducks"));
1425 DUCK_MASK(tangent,TANGENT,_("Show Tangent Ducks"));
1426 DUCK_MASK(vertex,VERTEX,_("Show Vertex Ducks"));
1427 DUCK_MASK(radius,RADIUS,_("Show Radius Ducks"));
1428 DUCK_MASK(width,WIDTH,_("Show Width Ducks"));
1429 DUCK_MASK(angle,ANGLE,_("Show Angle Ducks"));
1432 add_accel_group(App::ui_manager()->get_accel_group());
1434 /* // Here is where we add the actions that may have conflicting
1435 // keyboard accelerators.
1437 Glib::RefPtr<Gtk::ActionGroup> accel_action_group(Gtk::ActionGroup::create("canvas_view"));
1438 Glib::RefPtr<Gtk::Action> action;
1440 action=Gtk::Action::create("seek-next-frame", Gtk::StockID("gtk-forward"),_("Next Frame"),_("Next Frame"));
1441 accel_action_group->add(action,sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek),1));
1443 action=Gtk::Action::create("seek-prev-frame", Gtk::StockID("gtk-forward"),_("Prev Frame"),_("Prev Frame"));
1444 accel_action_group->add( action, sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek),-1));
1446 action=Gtk::Action::create("jump-next-keyframe", Gtk::StockID("gtk-forward"),_("Jump to Next Keyframe"),_("Jump to Next Keyframe"));
1447 accel_action_group->add( action,sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::jump_to_next_keyframe));
1449 action=Gtk::Action::create("jump-prev-keyframe", Gtk::StockID("gtk-back"),_("Jump to Prev Keyframe"),_("Jump to Prev Keyframe"));
1450 accel_action_group->add( action,sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::jump_to_prev_keyframe));
1452 action=Gtk::Action::create("canvas-zoom-in", Gtk::StockID("gtk-zoom-in"));
1453 accel_action_group->add( action,sigc::mem_fun(*work_area, &studio::WorkArea::zoom_in));
1455 action=Gtk::Action::create("canvas-zoom-out", Gtk::StockID("gtk-zoom-out"));
1456 accel_action_group->add( action, sigc::mem_fun(*work_area, &studio::WorkArea::zoom_out) );
1458 action=Gtk::Action::create("time-zoom-in", Gtk::StockID("gtk-zoom-in"), _("Zoom In on Timeline"));
1459 accel_action_group->add( action, sigc::mem_fun(*this, &studio::CanvasView::time_zoom_in) );
1461 action=Gtk::Action::create("time-zoom-out", Gtk::StockID("gtk-zoom-out"), _("Zoom Out on Timeline"));
1462 accel_action_group->add( action, sigc::mem_fun(*this, &studio::CanvasView::time_zoom_out) );
1464 Glib::RefPtr<Gtk::UIManager> accel_ui_manager(Gtk::UIManager::create());
1466 Glib::ustring ui_info =
1469 <accelerator action='seek-next-frame' />
1470 <accelerator action='seek-prev-frame' />
1471 <accelerator action='jump-next-keyframe' />
1472 <accelerator action='jump-prev-keyframe' />
1473 <accelerator action='canvas-zoom-in' />
1474 <accelerator action='canvas-zoom-out' />
1475 <accelerator action='time-zoom-in' />
1476 <accelerator action='time-zoom-out' />
1480 accel_ui_manager->add_ui_from_string(ui_info);
1481 add_accel_group(accel_ui_manager->get_accel_group());
1483 accel_ui_manager->insert_action_group(accel_action_group);
1484 set_ref_obj("accel_ui_manager",accel_ui_manager);
1485 set_ref_obj("accel_action_group",accel_action_group);
1493 // //Test some key stuff
1495 // filemenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-save"),
1496 // hide_return(sigc::mem_fun(*get_instance().get(), &studio::Instance::save))));
1497 // filemenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-save-as"),sigc::hide_return(sigc::mem_fun(*get_instance(), &studio::Instance::dialog_save_as))));
1498 // filemenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-revert-to-saved"),hide_return(sigc::mem_fun(*get_instance().get(), &studio::Instance::safe_revert))));
1499 // filemenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
1501 // filemenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("synfig-cvs_add"),sigc::hide_return(sigc::mem_fun(*get_instance(), &studio::Instance::dialog_cvs_add))));
1502 // filemenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("synfig-cvs_update"),sigc::hide_return(sigc::mem_fun(*get_instance(), &studio::Instance::dialog_cvs_update))));
1503 // filemenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("synfig-cvs_commit"),sigc::hide_return(sigc::mem_fun(*get_instance(), &studio::Instance::dialog_cvs_commit))));
1505 // filemenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
1506 // filemenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Import..."),Gtk::AccelKey('I',Gdk::CONTROL_MASK),sigc::hide_return(sigc::mem_fun(*this, &studio::CanvasView::image_import))));
1507 // filemenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
1508 // filemenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Render"),Gtk::AccelKey("F9"),
1509 // sigc::mem_fun(render_settings,&studio::RenderSettings::present)
1511 // filemenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Preview"),Gtk::AccelKey("F11"),
1512 // sigc::mem_fun(*this,&CanvasView::on_preview_option)
1514 // filemenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Sound File"),
1515 // sigc::mem_fun(*this,&CanvasView::on_audio_option)
1518 // filemenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
1519 // filemenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Options"),Gtk::AccelKey("F12"),
1520 // sigc::mem_fun(canvas_options,&studio::CanvasOptions::present)
1522 // filemenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
1523 // filemenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Close View"),
1524 // sigc::hide_return(sigc::mem_fun(*this,&studio::CanvasView::close_view))
1526 // filemenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Close Document"),
1527 // sigc::hide_return(sigc::mem_fun(*this,&studio::CanvasView::close_document))
1530 // editmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-undo"),Gtk::AccelKey('Z',Gdk::CONTROL_MASK),SLOT_EVENT(EVENT_UNDO)));
1531 // editmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-redo"),Gtk::AccelKey('R',Gdk::CONTROL_MASK),SLOT_EVENT(EVENT_REDO)));
1532 // editmenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
1533 // editmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-cut"),NOT_IMPLEMENTED_SLOT));
1534 // editmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-copy"),NOT_IMPLEMENTED_SLOT));
1535 // editmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-paste"),NOT_IMPLEMENTED_SLOT));
1536 // editmenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
1537 // editmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Select All Ducks"),Gtk::AccelKey('E',Gdk::CONTROL_MASK),sigc::mem_fun(*work_area,&studio::WorkArea::select_all_ducks)));
1538 // editmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Unselect All Layers"),Gtk::AccelKey('D',Gdk::CONTROL_MASK),sigc::mem_fun(*this,&CanvasView::on_unselect_layers)));
1539 // editmenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
1541 // //editmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-stop"),Gtk::AccelKey(GDK_Escape,static_cast<Gdk::ModifierType>(0)),sigc::hide_return(sigc::mem_fun(*this, &studio::CanvasView::stop))));
1542 // //editmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-refresh"),Gtk::AccelKey('k',Gdk::CONTROL_MASK),sigc::hide_return(sigc::mem_fun(*this, &studio::CanvasView::on_refresh_pressed))));
1543 // editmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-stop"),Gtk::AccelKey(GDK_Escape,static_cast<Gdk::ModifierType>(0)),SLOT_EVENT(EVENT_STOP)));
1544 // editmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-refresh"),Gtk::AccelKey('k',Gdk::CONTROL_MASK),SLOT_EVENT(EVENT_REFRESH)));
1545 // editmenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
1546 // editmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-properties"),Gtk::AccelKey("F8"),
1547 // sigc::mem_fun(canvas_properties,&studio::CanvasProperties::present)
1550 // build_new_layer_menu(newlayermenu);
1551 // layermenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("New"),newlayermenu));
1555 // synfigapp::Action::ParamList param_list;
1556 // param_list.add("canvas",Canvas::Handle(get_canvas()));
1557 // param_list.add("canvas_interface",canvas_interface());
1558 // add_actions_to_menu(&canvasmenu, param_list,synfigapp::Action::CATEGORY_CANVAS);
1562 // //canvasmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Keyframe Dialog"),sigc::mem_fun(keyframe_dialog,&studio::Dialog_Keyframe::present)));
1564 // // Duck Mask Menu
1567 // duckmaskmenu.items().push_back(Gtk::Menu_Helpers::TearoffMenuElem());
1569 // duckmaskmenu.items().push_back(Gtk::Menu_Helpers::CheckMenuElem(_("Position Ducks"),Gtk::AccelKey('1',Gdk::MOD1_MASK)));
1570 // duck_mask_position=static_cast<Gtk::CheckMenuItem*>(&duckmaskmenu.items().back());
1571 // duck_mask_position->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_POSITION));
1572 // duck_mask_position->signal_toggled().connect(
1574 // sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask),
1575 // Duck::TYPE_POSITION
1579 // duckmaskmenu.items().push_back(Gtk::Menu_Helpers::CheckMenuElem(_("Vertex Ducks"),Gtk::AccelKey('2',Gdk::MOD1_MASK)));
1580 // duck_mask_vertex=static_cast<Gtk::CheckMenuItem*>(&duckmaskmenu.items().back());
1581 // duck_mask_vertex->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_VERTEX));
1582 // duck_mask_vertex->signal_toggled().connect(
1584 // sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask),
1585 // Duck::TYPE_VERTEX
1589 // duckmaskmenu.items().push_back(Gtk::Menu_Helpers::CheckMenuElem(_("Tangent Ducks"),Gtk::AccelKey('3',Gdk::MOD1_MASK)));
1590 // duck_mask_tangent=static_cast<Gtk::CheckMenuItem*>(&duckmaskmenu.items().back());
1591 // duck_mask_tangent->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_TANGENT));
1592 // duck_mask_tangent->signal_toggled().connect(
1594 // sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask),
1595 // Duck::TYPE_TANGENT
1599 // duckmaskmenu.items().push_back(Gtk::Menu_Helpers::CheckMenuElem(_("Radius Ducks"),Gtk::AccelKey('4',Gdk::MOD1_MASK)));
1600 // duck_mask_radius=static_cast<Gtk::CheckMenuItem*>(&duckmaskmenu.items().back());
1601 // duck_mask_radius->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_RADIUS));
1602 // duck_mask_radius->signal_toggled().connect(
1604 // sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask),
1605 // Duck::TYPE_RADIUS
1609 // duckmaskmenu.items().push_back(Gtk::Menu_Helpers::CheckMenuElem(_("Width Ducks"),Gtk::AccelKey('5',Gdk::MOD1_MASK)));
1610 // duck_mask_width=static_cast<Gtk::CheckMenuItem*>(&duckmaskmenu.items().back());
1611 // duck_mask_width->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_WIDTH));
1612 // duck_mask_width->signal_toggled().connect(
1614 // sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask),
1619 // duckmaskmenu.items().push_back(Gtk::Menu_Helpers::CheckMenuElem(_("Angle Ducks"),Gtk::AccelKey('6',Gdk::MOD1_MASK)));
1620 // duck_mask_angle=static_cast<Gtk::CheckMenuItem*>(&duckmaskmenu.items().back());
1621 // duck_mask_angle->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_ANGLE));
1622 // duck_mask_angle->signal_toggled().connect(
1624 // sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask),
1629 // viewmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Mask Ducks"),duckmaskmenu));
1632 // // Preview Quality Menu
1635 // qualitymenu.items().push_back(Gtk::Menu_Helpers::TearoffMenuElem());
1637 // qualitymenu.items().push_back(Gtk::Menu_Helpers::MenuElem(strprintf(_("Use Parametric Renderer"),0),
1639 // sigc::mem_fun(*work_area, &studio::WorkArea::set_quality),
1643 // for(i=1;i<=10;i++)
1645 // qualitymenu.items().push_back(Gtk::Menu_Helpers::MenuElem(strprintf(_("Set Quality to %d"),i),Gtk::AccelKey('0'+(i%10),Gdk::CONTROL_MASK),
1647 // sigc::mem_fun(*work_area, &studio::WorkArea::set_quality),
1652 // viewmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Preview Quality"),qualitymenu));
1655 // viewmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::MEDIA_PLAY,
1656 // sigc::mem_fun(*this, &studio::CanvasView::play)));
1657 // viewmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("Flipbook Dialog"),
1658 // sigc::mem_fun(*preview_dialog, &studio::Dialog_Preview::present)));
1660 // viewmenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
1662 // viewmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Toggle Grid Show"),Gtk::AccelKey('g',Gdk::CONTROL_MASK),
1663 // sigc::mem_fun(*work_area, &studio::WorkArea::toggle_grid)));
1664 // viewmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Toggle Grid Snap"),Gtk::AccelKey('l',Gdk::CONTROL_MASK),
1665 // sigc::mem_fun(*work_area, &studio::WorkArea::toggle_grid_snap)));
1666 // viewmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Toggle Guide Snap"),Gtk::AccelKey('k',Gdk::CONTROL_MASK),
1667 // sigc::mem_fun(*work_area, &studio::WorkArea::toggle_guide_snap)));
1668 // viewmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Toggle Low-Res"),Gtk::AccelKey('`',Gdk::CONTROL_MASK),
1669 // sigc::mem_fun(*work_area, &studio::WorkArea::toggle_low_resolution_flag)));
1671 // viewmenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
1673 // viewmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-zoom-in"),Gtk::AccelKey('=',static_cast<Gdk::ModifierType>(0)),
1674 // sigc::mem_fun(*work_area, &studio::WorkArea::zoom_in)));
1675 // viewmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-zoom-out"),Gtk::AccelKey('-',static_cast<Gdk::ModifierType>(0)),
1676 // sigc::mem_fun(*work_area, &studio::WorkArea::zoom_out)));
1677 // viewmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-zoom-fit"),
1678 // sigc::mem_fun(*work_area, &studio::WorkArea::zoom_fit)));
1679 // viewmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-zoom-100"),Gtk::AccelKey('`',static_cast<Gdk::ModifierType>(0)),
1680 // sigc::mem_fun(*work_area, &studio::WorkArea::zoom_norm)));
1681 // viewmenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
1683 // viewmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-zoom-in"),Gtk::AccelKey('+',static_cast<Gdk::ModifierType>(0)),
1684 // sigc::mem_fun(*this, &studio::CanvasView::time_zoom_in)));
1685 // viewmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-zoom-out"),Gtk::AccelKey('_',static_cast<Gdk::ModifierType>(0)),
1686 // sigc::mem_fun(*this, &studio::CanvasView::time_zoom_out)));
1688 // viewmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Jump to Next Keyframe"),Gtk::AccelKey(']',static_cast<Gdk::ModifierType>(0)),
1689 // sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::jump_to_next_keyframe)));
1690 // viewmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Jump to Prev Keyframe"),Gtk::AccelKey('[',static_cast<Gdk::ModifierType>(0)),
1691 // sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::jump_to_prev_keyframe)));
1693 // mainmenu.items().push_back(Gtk::Menu_Helpers::TearoffMenuElem());
1694 // mainmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("_File"),filemenu));
1695 // mainmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Edit"),editmenu));
1696 // mainmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("_View"),viewmenu));
1697 // mainmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Canvas"),canvasmenu));
1698 // mainmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Layer"),layermenu));
1700 // mainmenu.accelerate(*this);
1705 // trackmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("New Waypoint"),NOT_IMPLEMENTED_SLOT));
1706 // trackmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Delete Waypoint"),NOT_IMPLEMENTED_SLOT));
1707 // trackmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Export"),NOT_IMPLEMENTED_SLOT));
1708 // trackmenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
1709 // trackmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Properties"),NOT_IMPLEMENTED_SLOT));
1715 // canvasmenu.show();
1716 // layermenu.show();
1718 // keyframemenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-properties"),
1719 // sigc::mem_fun(*this,&studio::CanvasView::show_keyframe_dialog)
1723 // get_accel_group()->unlock();
1725 // //Set the accelerator paths for all the menus
1726 // filemenu.set_accel_path("<synfig>/File");
1727 // editmenu.set_accel_path("<synfig>/Edit");
1728 // layermenu.set_accel_path("<synfig>/Layer");
1729 // //mainmenu.set_accel_path("<synfig-main>");
1730 // canvasmenu.set_accel_path("<synfig>/Canvas");
1731 // viewmenu.set_accel_path("<synfig>/View");
1732 // duckmaskmenu.set_accel_path("<synfig>/DuckMask");
1737 CanvasView::on_unselect_layers()
1739 layer_tree->clear_selected_layers();
1743 CanvasView::show_keyframe_dialog()
1745 Glib::RefPtr<Gtk::TreeSelection> selection(keyframe_tree->get_selection());
1746 if(selection->get_selected())
1748 Gtk::TreeRow row(*selection->get_selected());
1750 Keyframe keyframe(row[keyframe_tree->model.keyframe]);
1752 keyframe_dialog.set_keyframe(keyframe);
1753 keyframe_dialog.present();
1758 CanvasView::add_layer(synfig::String x)
1760 Canvas::Handle canvas;
1762 synfigapp::SelectionManager::LayerList layer_list(get_selection_manager()->get_selected_layers());
1764 int target_depth(0);
1766 if(layer_list.empty())
1768 canvas=get_canvas();
1772 canvas=(*layer_list.begin())->get_canvas();
1773 target_depth=canvas->get_depth(*layer_list.begin());
1777 Layer::Handle layer(canvas_interface()->add_layer_to(x,canvas,target_depth));
1780 get_selection_manager()->clear_selected_layers();
1781 get_selection_manager()->set_selected_layer(layer);
1786 CanvasView::popup_layer_menu(synfig::Layer::Handle layer)
1788 //Gtk::Menu* menu(manage(new Gtk::Menu));
1789 Gtk::Menu* menu(¶mmenu);
1790 menu->items().clear();
1792 synfigapp::Action::ParamList param_list;
1793 param_list.add("time",canvas_interface()->get_time());
1794 param_list.add("canvas",Canvas::Handle(layer->get_canvas()));
1795 param_list.add("canvas_interface",canvas_interface());
1796 param_list.add("layer",layer);
1798 //Gtk::Menu *newlayers(manage(new Gtk::Menu()));
1799 //build_new_layer_menu(*newlayers);
1801 //parammenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("New Layer"),*newlayers));
1803 if(layer->get_name()=="PasteCanvas")
1805 menu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Select All Children"),
1809 &studio::LayerTree::select_all_children_layers
1816 add_actions_to_menu(menu, param_list,synfigapp::Action::CATEGORY_LAYER);
1818 menu->popup(3,gtk_get_current_event_time());
1822 CanvasView::register_layer_type(synfig::Layer::Book::value_type &/*lyr*/,std::map<synfig::String,Gtk::Menu*>* /*category_map*/)
1824 /* if(lyr.second.category==CATEGORY_DO_NOT_USE)
1827 if(category_map->count(lyr.second.category)==0)
1828 (*category_map)[lyr.second.category]=manage(new Gtk::Menu());
1830 (*category_map)[lyr.second.category]->items().push_back(Gtk::Menu_Helpers::MenuElem(lyr.second.local_name,
1833 sigc::mem_fun(*this,&studio::CanvasView::add_layer),
1842 CanvasView::build_new_layer_menu(Gtk::Menu &/*menu*/)
1845 std::map<synfig::String,Gtk::Menu*> category_map;
1848 synfig::Layer::book().begin(),
1849 synfig::Layer::book().end(),
1853 &studio::CanvasView::register_layer_type
1859 menu.items().clear();
1860 menu.items().push_back(Gtk::Menu_Helpers::TearoffMenuElem());
1862 std::map<synfig::String,Gtk::Menu*>::iterator iter;
1863 for(iter=category_map.begin();iter!=category_map.end();++iter)
1864 menu.items().push_back(Gtk::Menu_Helpers::MenuElem(iter->first,*iter->second));
1871 CanvasView::popup_main_menu()
1873 //mainmenu.popup(0,gtk_get_current_event_time());
1874 Gtk::Menu* menu = dynamic_cast<Gtk::Menu*>(App::ui_manager()->get_widget("/menu-main"));
1877 //menu->set_accel_group(App::ui_manager()->get_accel_group());
1878 //menu->accelerate(*this);
1879 menu->popup(0,gtk_get_current_event_time());
1884 CanvasView::on_refresh_pressed()
1888 work_area->queue_render_preview();
1892 CanvasView::workarea_layer_selected(synfig::Layer::Handle layer)
1894 get_selection_manager()->clear_selected_layers();
1896 get_selection_manager()->set_selected_layer(layer);
1901 CanvasView::refresh_rend_desc()
1903 current_time_widget->set_fps(get_canvas()->rend_desc().get_frame_rate());
1907 //synfig::info("Canvasview: Refreshing render desc info");
1908 if(!get_time().is_equal(time_adjustment().get_value()))
1910 time_adjustment().set_value(get_time());
1911 time_adjustment().value_changed();
1914 Time length(get_canvas()->rend_desc().get_time_end()-get_canvas()->rend_desc().get_time_start());
1915 if(length<DEFAULT_TIME_WINDOW_SIZE)
1917 time_window_adjustment().set_page_increment(length);
1918 time_window_adjustment().set_page_size(length);
1922 time_window_adjustment().set_page_increment(DEFAULT_TIME_WINDOW_SIZE);
1923 time_window_adjustment().set_page_size(DEFAULT_TIME_WINDOW_SIZE);
1926 //set the FPS of the timeslider
1927 timeslider->set_global_fps(get_canvas()->rend_desc().get_frame_rate());
1929 //set the beginning and ending time of the time slider
1930 Time begin_time=get_canvas()->rend_desc().get_time_start();
1931 Time end_time=get_canvas()->rend_desc().get_time_end();
1933 // Setup the time_window adjustment
1934 time_window_adjustment().set_lower(begin_time);
1935 time_window_adjustment().set_upper(end_time);
1936 time_window_adjustment().set_step_increment(synfig::Time(1.0/get_canvas()->rend_desc().get_frame_rate()));
1938 //Time length(get_canvas()->rend_desc().get_time_end()-get_canvas()->rend_desc().get_time_start());
1939 if(length < time_window_adjustment().get_page_size())
1941 time_window_adjustment().set_page_increment(length);
1942 time_window_adjustment().set_page_size(length);
1945 /*synfig::info("w: %p - [%.3f,%.3f] (%.3f,%.3f) child: %p\n",
1946 &time_window_adjustment_, time_window_adjustment_.get_lower(),
1947 time_window_adjustment_.get_upper(),time_window_adjustment_.get_value(),
1948 time_window_adjustment_.get_page_size(),time_window_adjustment_.get_child_adjustment()
1951 time_window_adjustment().changed(); //only non-value stuff was changed
1953 // Setup the time adjustment
1955 //NOTE THESE TWO SHOULD BE CHANGED BY THE changed() CALL ABOVE
1956 //time_adjustment().set_lower(time_window_adjustment().get_value());
1957 //time_adjustment().set_upper(time_window_adjustment().get_value()+time_window_adjustment().get_page_size());
1959 // time_adjustment().set_lower(get_canvas()->rend_desc().get_time_start());
1960 // time_adjustment().set_upper(get_canvas()->rend_desc().get_time_end());
1961 time_adjustment().set_step_increment(synfig::Time(1.0/get_canvas()->rend_desc().get_frame_rate()));
1962 time_adjustment().set_page_increment(synfig::Time(1.0));
1963 time_adjustment().set_page_size(0);
1965 time_adjustment().changed();
1967 /*synfig::info("w: %p - [%.3f,%.3f] (%.3f,%.3f) child: %p\n",
1968 &time_window_adjustment_, time_window_adjustment_.get_lower(),
1969 time_window_adjustment_.get_upper(),time_window_adjustment_.get_value(),
1970 time_window_adjustment_.get_page_size(),time_window_adjustment_.get_child_adjustment()
1973 if(begin_time==end_time)
1982 //clamp time to big bounds...
1983 if(time_adjustment().get_value() < begin_time)
1985 time_adjustment().set_value(begin_time);
1986 time_adjustment().value_changed();
1989 if(time_adjustment().get_value() > end_time)
1991 time_adjustment().set_value(end_time);
1992 time_adjustment().value_changed();
1995 /*synfig::info("Time stats: \n"
1996 "w: %p - [%.3f,%.3f] (%.3f,%.3f) child: %p\n"
1997 "t: %p - [%.3f,%.3f] %.3f",
1998 &time_window_adjustment_, time_window_adjustment_.get_lower(),
1999 time_window_adjustment_.get_upper(),time_window_adjustment_.get_value(),
2000 time_window_adjustment_.get_page_size(),time_window_adjustment_.get_child_adjustment(),
2001 &time_adjustment_,time_adjustment_.get_lower(),time_adjustment_.get_upper(),
2002 time_adjustment_.get_value()
2005 work_area->queue_render_preview();
2010 CanvasView::close_view()
2012 if(get_instance()->get_visible_canvases()==1)
2019 static bool _close_instance(etl::handle<Instance> instance)
2021 etl::handle<Instance> argh(instance);
2022 instance->safe_close();
2023 synfig::info("closed");
2028 CanvasView::close_instance()
2030 if (get_work_area()->get_updating())
2032 get_work_area()->stop_updating(true); // stop and mark as cancelled
2034 // give the workarea chances to stop updating
2035 Glib::signal_timeout().connect(
2036 sigc::mem_fun(*this, &CanvasView::close_instance),
2040 Glib::signal_timeout().connect(
2041 sigc::bind(sigc::ptr_fun(_close_instance),
2042 (etl::handle<Instance>)get_instance()),
2048 CanvasView::create(etl::loose_handle<Instance> instance, etl::handle<synfig::Canvas> canvas)
2050 etl::handle<studio::CanvasView> view(new CanvasView(instance,instance->synfigapp::Instance::find_canvas_interface(canvas)));
2051 instance->canvas_view_list().push_front(view);
2052 instance->signal_canvas_view_created()(view.get());
2057 CanvasView::update_title()
2061 if(get_instance()->synfigapp::Instance::get_action_count())
2063 title+=etl::basename(get_instance()->get_file_name())
2065 if(get_canvas()->get_name().empty())
2066 title+='"'+get_canvas()->get_id()+'"';
2068 title+='"'+get_canvas()->get_name()+'"';
2070 if(get_instance()->synfigapp::Instance::in_repository())
2073 if(get_instance()->synfigapp::Instance::is_modified())
2074 title+=_("-MODIFIED");
2075 if(get_instance()->synfigapp::Instance::is_updated())
2076 title+=_("-UPDATED");
2080 if(get_canvas()->is_root())
2081 title+=_(" (Root)");
2088 CanvasView::on_hide()
2091 Gtk::Window::on_hide();
2095 CanvasView::present()
2097 grab_focus();//on_focus_in_event(0);
2098 Gtk::Window::present();
2102 CanvasView::on_focus_in_event(GdkEventFocus*x)
2104 if(studio::App::get_selected_canvas_view()!=this)
2106 if(studio::App::get_selected_canvas_view())
2108 studio::App::get_selected_canvas_view()->get_smach().process_event(EVENT_YIELD_TOOL_OPTIONS);
2109 App::ui_manager()->remove_action_group(App::get_selected_canvas_view()->action_group);
2112 get_smach().process_event(EVENT_REFRESH_TOOL_OPTIONS);
2114 studio::App::set_selected_canvas_view(this);
2116 App::ui_manager()->insert_action_group(action_group);
2119 // HACK ... Questionable...?
2121 return Gtk::Window::on_focus_in_event(x);
2127 CanvasView::on_focus_out_event(GdkEventFocus*x)
2129 //App::ui_manager()->remove_action_group(action_group);
2130 //App::ui_manager()->ensure_update();
2131 return Gtk::Window::on_focus_out_event(x);
2135 CanvasView::refresh_tables()
2137 // if(layer_tree_store_)layer_tree_store_->refresh();
2138 // if(children_tree_store_)children_tree_store_->refresh();
2142 CanvasView::rebuild_tables()
2144 // layer_tree_store_->rebuild();
2145 // children_tree_store_->rebuild();
2149 CanvasView::build_tables()
2151 // layer_tree_store_->rebuild();
2152 // children_tree_store_->rebuild();
2156 CanvasView::on_layer_toggle(synfig::Layer::Handle layer)
2158 synfigapp::Action::Handle action(synfigapp::Action::create("layer_activate"));
2164 action->set_param("canvas",Canvas::Handle(layer->get_canvas()));
2165 if(!action->set_param("canvas_interface",canvas_interface()))
2166 // if(!action->set_param("canvas_interface",get_instance()->find_canvas_interface(layer->get_canvas())))
2167 synfig::error("LayerActivate didn't like CanvasInterface...?");
2168 action->set_param("time",get_time());
2169 action->set_param("layer",layer);
2170 action->set_param("new_status",!layer->active());
2172 assert(action->is_ready());
2174 canvas_interface()->get_instance()->perform_action(action);
2179 CanvasView::popup_param_menu(synfigapp::ValueDesc value_desc, float location)
2181 parammenu.items().clear();
2182 get_instance()->make_param_menu(¶mmenu,get_canvas(),value_desc,location);
2184 parammenu.popup(3,gtk_get_current_event_time());
2188 CanvasView::add_actions_to_menu(Gtk::Menu *menu, const synfigapp::Action::ParamList ¶m_list,synfigapp::Action::Category category)const
2190 get_instance()->add_actions_to_menu(menu, param_list, category);
2194 CanvasView::on_layer_user_click(int button, Gtk::TreeRow /*row*/, LayerTree::ColumnID /*column_id*/)
2201 Gtk::MenuItem* menu = dynamic_cast<Gtk::MenuItem*>(App::ui_manager()->get_widget("/menu-main/menu-layer"));
2202 if(menu && menu->get_submenu())
2204 //menu->set_accel_group(App::ui_manager()->get_accel_group());
2205 //menu->accelerate(*this);
2206 menu->get_submenu()->popup(button,gtk_get_current_event_time());
2211 bool multiple_selected=true;
2213 if(layer_tree->get_selection()->count_selected_rows()<=1)
2214 multiple_selected=false;
2216 // If the clicked row is not selected, then unselect
2217 // everything that isn't selected and select this row
2218 if(multiple_selected && !layer_tree->get_selection()->is_selected(row))
2220 layer_tree->get_selection()->unselect_all();
2221 layer_tree->get_selection()->select(row);
2222 multiple_selected=false;
2225 if(column_id==COLUMNID_TIME_TRACK)
2228 //synfigapp::ValueDesc value_desc(row[layer_param_tree_model.value_desc]);
2229 //ValueNode::Handle value_node(row[layer_param_tree_model.value_node]);
2230 //ValueNode::Handle parent_value_node;
2231 //ValueBase value=row[layer_param_tree_model.value];
2235 // parent_value_node=(*row.parent())[layer_tree_model.value_node];
2239 Layer::Handle layer(row[layer_tree_model.layer]);
2240 synfigapp::Action::ParamList param_list;
2241 param_list.add("time",canvas_interface()->get_time());
2242 param_list.add("canvas",Canvas::Handle(row[layer_tree_model.canvas]));
2243 param_list.add("canvas_interface",canvas_interface());
2244 if(!multiple_selected)
2245 param_list.add("layer",layer);
2248 synfigapp::SelectionManager::LayerList layer_list(get_selection_manager()->get_selected_layers());
2249 synfigapp::SelectionManager::LayerList::iterator iter;
2251 for(iter=layer_list.begin();iter!=layer_list.end();++iter)
2252 param_list.add("layer",Layer::Handle(*iter));
2255 parammenu.items().clear();
2257 Gtk::Menu *newlayers(manage(new Gtk::Menu()));
2258 // do we need this? the code is all #ifdef'ed out anyway
2259 // newlayers->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), newlayers));
2260 build_new_layer_menu(*newlayers);
2262 parammenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("New Layer"),*newlayers));
2263 if(!multiple_selected && layer->get_name()=="PasteCanvas")
2265 parammenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Select All Children"),
2269 &studio::LayerTree::select_all_children_layers
2276 add_actions_to_menu(¶mmenu, param_list,synfigapp::Action::CATEGORY_LAYER);
2277 parammenu.popup(button,gtk_get_current_event_time());
2281 else if(column_id==LayerTree::COLUMNID_TIME_TRACK && value_node && handle<synfig::ValueNode_Animated>::cast_dynamic(value_node))
2283 // Right-click on time track with animated
2284 // trackmenu.popup(0,0);
2289 if(!multiple_selected)
2291 popup_param_menu(value_desc);
2298 parammenu.items().clear();
2299 parammenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Connect"),
2300 hide_return(sigc::mem_fun(*canvas_interface().get(),&synfigapp::CanvasInterface::connect_selected_layer_params))
2302 parammenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Disconnect"),
2303 hide_return(sigc::mem_fun(*canvas_interface().get(),&synfigapp::CanvasInterface::disconnect_selected_layer_params))
2305 parammenu.popup(0,0);
2325 CanvasView::on_children_user_click(int button, Gtk::TreeRow row, ChildrenTree::ColumnID column_id)
2331 if(column_id==COLUMNID_TIME_TRACK)
2333 if(!(bool)row[children_tree_model.is_canvas])
2335 synfigapp::ValueDesc value_desc=row[children_tree_model.value_desc];
2338 //! \todo fix properly -- what is the child dialog for?
2339 synfig::info("preventing child dialog right-click crash");
2343 popup_param_menu(value_desc);
2357 CanvasView::on_keyframe_tree_event(GdkEvent *event)
2361 case GDK_BUTTON_PRESS:
2362 switch(event->button.button)
2366 //keyframemenu.popup(event->button.button,gtk_get_current_event_time());
2372 case GDK_MOTION_NOTIFY:
2374 case GDK_BUTTON_RELEASE:
2384 CanvasView::refresh_time_window()
2386 //THESE SHOULD AUTOMATICALLY BE TAKEN CARE OF
2387 //time_adjustment().set_lower(time_window_adjustment().get_value());
2388 //time_adjustment().set_upper(time_window_adjustment().get_value()+time_window_adjustment().get_page_size());
2390 time_adjustment().set_page_increment(1.0); // One second
2391 time_adjustment().set_page_size(0);
2394 time_adjustment().set_step_increment(1.0/get_canvas()->rend_desc().get_frame_rate());
2395 time_adjustment().changed();
2397 //NOTE THIS SHOULD HOOK INTO THE CORRECT SIGNALS...
2399 children_tree->queue_draw();
2403 CanvasView::on_time_changed()
2405 Time time(get_time());
2407 current_time_widget->set_value(time);
2409 get_canvas()->keyframe_list().find(time);
2410 current_time_widget->modify_text(Gtk::STATE_NORMAL,Gdk::Color("#FF0000"));
2412 current_time_widget->modify_text(Gtk::STATE_NORMAL,Gdk::Color("#000000"));
2415 if(get_time() != time_adjustment().get_value())
2418 //Recenters the window, causing it to jump (possibly undesirably... but whatever)
2419 if(time < time_window_adjustment().get_value() ||
2420 time > time_window_adjustment().get_value()+time_window_adjustment().get_page_size())
2422 time_window_adjustment().set_value(
2423 time-time_window_adjustment().get_page_size()/2
2426 time_adjustment().set_value(time);
2427 time_adjustment().value_changed();
2429 // Shouldn't these trees just hook into
2430 // the time changed signal...?
2431 //YES THEY SHOULD...
2432 if(layer_tree)layer_tree->queue_draw();
2433 if(children_tree)children_tree->queue_draw();
2438 CanvasView::time_zoom_in()
2440 time_window_adjustment().set_page_size(time_window_adjustment().get_page_size()*0.75);
2441 time_window_adjustment().changed();
2443 refresh_time_window();
2447 CanvasView::time_zoom_out()
2449 time_window_adjustment().set_page_size(time_window_adjustment().get_page_size()/0.75);
2450 time_window_adjustment().changed();
2452 refresh_time_window();
2456 CanvasView::time_was_changed()
2458 synfig::Time time((synfig::Time)(double)time_adjustment().get_value());
2463 CanvasView::on_edited_value(synfigapp::ValueDesc value_desc,synfig::ValueBase new_value)
2465 canvas_interface()->change_value(value_desc,new_value);
2470 CanvasView::on_children_edited_value(const Glib::ustring&path_string,synfig::ValueBase value)
2472 Gtk::TreePath path(path_string);
2474 const Gtk::TreeRow row = *(children_tree->get_model()->get_iter(path));
2476 assert((bool)row[children_tree_model.is_value_node]);
2478 synfigapp::ValueDesc value_desc=row[children_tree_model.value_desc];
2481 on_edited_value(value_desc,value);
2486 CanvasView::on_id_changed()
2493 CanvasView::on_mode_changed(synfigapp::CanvasInterface::Mode mode)
2495 // If the animate flag was set in mode...
2496 if(mode&synfigapp::MODE_ANIMATE)
2499 icon=manage(new Gtk::Image(Gtk::StockID("gtk-no"),Gtk::ICON_SIZE_BUTTON));
2500 animatebutton->remove();
2501 animatebutton->add(*icon);
2502 tooltips.set_tip(*animatebutton,_("In Animate Editing Mode"));
2503 icon->set_padding(0,0);
2509 icon=manage(new Gtk::Image(Gtk::StockID("gtk-yes"),Gtk::ICON_SIZE_BUTTON));
2510 animatebutton->remove();
2511 animatebutton->add(*icon);
2512 tooltips.set_tip(*animatebutton,_("Not in Animate Editing Mode"));
2513 icon->set_padding(0,0);
2517 if((mode&synfigapp::MODE_ANIMATE_FUTURE) && (mode&synfigapp::MODE_ANIMATE_PAST))
2520 icon=manage(new Gtk::Image(Gtk::StockID("synfig-keyframe_lock_all"),Gtk::ICON_SIZE_BUTTON));
2521 keyframebutton->remove();
2522 keyframebutton->add(*icon);
2523 tooltips.set_tip(*keyframebutton,_("All Keyframes Locked"));
2524 icon->set_padding(0,0);
2527 else if((mode&synfigapp::MODE_ANIMATE_FUTURE) && !(mode&synfigapp::MODE_ANIMATE_PAST))
2530 icon=manage(new Gtk::Image(Gtk::StockID("synfig-keyframe_lock_future"),Gtk::ICON_SIZE_BUTTON));
2531 keyframebutton->remove();
2532 keyframebutton->add(*icon);
2533 tooltips.set_tip(*keyframebutton,_("Future Keyframes Locked"));
2534 icon->set_padding(0,0);
2537 else if(!(mode&synfigapp::MODE_ANIMATE_FUTURE) && (mode&synfigapp::MODE_ANIMATE_PAST))
2540 icon=manage(new Gtk::Image(Gtk::StockID("synfig-keyframe_lock_past"),Gtk::ICON_SIZE_BUTTON));
2541 keyframebutton->remove();
2542 keyframebutton->add(*icon);
2543 tooltips.set_tip(*keyframebutton,_("Past Keyframes Locked"));
2544 icon->set_padding(0,0);
2547 else if(!(mode&synfigapp::MODE_ANIMATE_FUTURE) && !(mode&synfigapp::MODE_ANIMATE_PAST))
2550 icon=manage(new Gtk::Image(Gtk::StockID("synfig-keyframe_lock_none"),Gtk::ICON_SIZE_BUTTON));
2551 keyframebutton->remove();
2552 keyframebutton->add(*icon);
2553 tooltips.set_tip(*keyframebutton,_("No Keyframes Locked"));
2554 icon->set_padding(0,0);
2558 work_area->queue_draw();
2562 CanvasView::on_animate_button_pressed()
2564 if(get_mode()&synfigapp::MODE_ANIMATE)
2565 set_mode(get_mode()-synfigapp::MODE_ANIMATE);
2567 set_mode(get_mode()|synfigapp::MODE_ANIMATE);
2571 CanvasView::on_keyframe_button_pressed()
2573 synfigapp::CanvasInterface::Mode mode(get_mode());
2575 // future && past --> past
2576 if((mode&synfigapp::MODE_ANIMATE_FUTURE) && (mode&synfigapp::MODE_ANIMATE_PAST))
2577 set_mode(get_mode()-synfigapp::MODE_ANIMATE_FUTURE);
2579 else if(!(mode&synfigapp::MODE_ANIMATE_FUTURE) && (mode&synfigapp::MODE_ANIMATE_PAST))
2580 set_mode((get_mode()-synfigapp::MODE_ANIMATE_PAST)|synfigapp::MODE_ANIMATE_FUTURE);
2581 // future --> (nothing)
2582 else if((mode&synfigapp::MODE_ANIMATE_FUTURE) && !(mode&synfigapp::MODE_ANIMATE_PAST))
2583 set_mode(get_mode()-synfigapp::MODE_ANIMATE_FUTURE);
2584 // (nothing) --> future && past
2585 else if(!(mode&synfigapp::MODE_ANIMATE_FUTURE) && !(mode&synfigapp::MODE_ANIMATE_PAST))
2586 set_mode(get_mode()|synfigapp::MODE_ANIMATE_FUTURE|synfigapp::MODE_ANIMATE_PAST);
2590 CanvasView::duck_change_param(const synfig::Point &value,synfig::Layer::Handle layer, synfig::String param_name)
2592 return canvas_interface()->change_value(synfigapp::ValueDesc(layer,param_name),value);
2596 CanvasView::on_duck_changed(const synfig::Point &value,const synfigapp::ValueDesc& value_desc)
2598 switch(value_desc.get_value_type())
2600 case ValueBase::TYPE_REAL:
2601 return canvas_interface()->change_value(value_desc,value.mag());
2603 case ValueBase::TYPE_ANGLE:
2604 return canvas_interface()->change_value(value_desc,Angle::tan(value[1],value[0]));
2607 return canvas_interface()->change_value(value_desc,value);
2615 CanvasView::on_duck_angle_changed(const synfig::Angle &rotation,const synfigapp::ValueDesc& value_desc)
2617 // \todo will this really always be the case?
2618 assert(value_desc.get_value_type() == ValueBase::TYPE_ANGLE);
2619 return canvas_interface()->change_value(value_desc, value_desc.get_value(get_time()).get(Angle()) + rotation);
2623 CanvasView::selected_layer_color_set(synfig::Color color)
2625 synfigapp::SelectionManager::LayerList selected_list(get_selection_manager()->get_selected_layers());
2626 synfigapp::SelectionManager::LayerList::iterator iter;
2628 // Create the action group
2629 //synfigapp::PassiveGrouper group(canvas_interface()->get_instance(),_("Set Colors"));
2631 Layer::Handle layer;
2632 for(iter=selected_list.begin();iter!=selected_list.end();++iter)
2637 on_edited_value(synfigapp::ValueDesc(layer,"color"),color);
2642 CanvasView::rebuild_ducks_layer_(synfig::TransformStack& transform_stack, synfig::Canvas::Handle canvas, std::set<synfig::Layer::Handle>& selected_list)
2647 #define QUEUE_REBUILD_DUCKS sigc::mem_fun(*this,&CanvasView::queue_rebuild_ducks)
2651 synfig::warning("CanvasView::rebuild_ducks_layer_(): Layer doesn't have canvas set");
2654 for(Canvas::iterator iter(canvas->begin());iter!=canvas->end();++iter)
2656 Layer::Handle layer(*iter);
2658 if(selected_list.count(layer))
2660 if(!curr_transform_stack_set)
2662 curr_transform_stack_set=true;
2663 curr_transform_stack=transform_stack;
2666 // This layer is currently selected.
2667 duck_changed_connections.push_back(layer->signal_changed().connect(QUEUE_REBUILD_DUCKS));
2669 // do the bounding box thing
2670 bbox|=transform_stack.perform(layer->get_bounding_rect());
2672 // Grab the layer's list of parameters
2673 Layer::ParamList paramlist(layer->get_param_list());
2675 // Grab the layer vocabulary
2676 Layer::Vocab vocab=layer->get_param_vocab();
2677 Layer::Vocab::iterator iter;
2679 for(iter=vocab.begin();iter!=vocab.end();iter++)
2681 if(!iter->get_hidden() && !iter->get_invisible_duck())
2683 synfigapp::ValueDesc value_desc(layer,iter->get_name());
2684 work_area->add_to_ducks(value_desc,this,transform_stack,&*iter);
2685 if(value_desc.is_value_node())
2686 duck_changed_connections.push_back(value_desc.get_value_node()->signal_changed().connect(QUEUE_REBUILD_DUCKS));
2688 if(iter->get_name()=="color")
2691 if(!App::dialog_color->busy())
2693 App::dialog_color->reset();
2694 App::dialog_color->set_color(layer->get_param("color").get(Color()));
2695 App::dialog_color->signal_edited().connect(
2698 &studio::CanvasView::selected_layer_color_set
2707 layer_name=layer->get_name();
2711 Transform::Handle trans(layer->get_transform());
2714 transform_stack.push(trans);
2718 /* // Add transforms onto the stack
2719 if(layer_name=="Translate")
2721 transform_stack.push(synfig::Transform_Translate(layer->get_param("origin").get(Vector())));
2724 if(layer_name=="Zoom")
2727 scale[0]=scale[1]=exp(layer->get_param("amount").get(Real()));
2728 transform_stack.push(synfig::Transform_Scale(scale,layer->get_param("center").get(Vector())));
2731 if(layer_name=="stretch")
2733 Vector scale(layer->get_param("amount").get(Vector()));
2734 transform_stack.push(synfig::Transform_Scale(scale,layer->get_param("center").get(Vector())));
2737 if(layer_name=="Rotate")
2739 transform_stack.push(synfig::Transform_Rotate(layer->get_param("amount").get(Angle()),layer->get_param("origin").get(Vector())));
2745 // If this is a paste canvas layer, then we need to
2747 if(layer_name=="PasteCanvas")
2750 scale[0]=scale[1]=exp(layer->get_param("zoom").get(Real()));
2751 Vector origin(layer->get_param("origin").get(Vector()));
2753 Canvas::Handle child_canvas(layer->get_param("canvas").get(Canvas::Handle()));
2755 if(!scale.is_equal_to(Vector(1,1)))
2756 transform_stack.push(new Transform_Scale(scale,origin));
2757 if(!scale.is_equal_to(Vector(0,0)))
2758 transform_stack.push(new Transform_Translate(origin));
2760 rebuild_ducks_layer_(transform_stack,child_canvas,selected_list);
2762 if(!scale.is_equal_to(Vector(0,0)))
2763 transform_stack.pop();
2764 if(!scale.is_equal_to(Vector(1,1)))
2765 transform_stack.pop();
2768 // Remove all of the transforms we have added
2769 while(transforms--) { transform_stack.pop(); }
2771 #undef QUEUE_REBUILD_DUCKS
2775 CanvasView::queue_rebuild_ducks()
2778 if(rebuild_ducks_queued)
2781 if(rebuild_ducks_queued)
2782 queue_rebuild_ducks_connection.disconnect();
2785 queue_rebuild_ducks_connection=Glib::signal_timeout().connect(
2787 sigc::mem_fun(*this,&CanvasView::rebuild_ducks),
2793 rebuild_ducks_queued=true;
2797 CanvasView::rebuild_ducks()
2802 synfig::info("%d",i/(i-i));
2805 rebuild_ducks_queued=false;
2806 //queue_rebuild_ducks_connection.disconnect();
2808 if(work_area->is_dragging())
2810 queue_rebuild_ducks();
2814 if(!duck_refresh_flag)
2816 duck_refresh_needed=true;
2822 work_area->clear_ducks();
2823 work_area->set_time(get_time());
2824 get_canvas()->set_time(get_time());
2825 curr_transform_stack.clear();
2826 //curr_transform_stack.push(new Transform_Translate(Point(0,0)));
2827 curr_transform_stack_set=false;
2829 for(;!duck_changed_connections.empty();duck_changed_connections.pop_back())duck_changed_connections.back().disconnect();
2831 //get_canvas()->set_time(get_time());
2832 bool not_empty(false);
2834 // First do the layers...
2836 synfigapp::SelectionManager::LayerList selected_list(get_selection_manager()->get_selected_layers());
2837 std::set<synfig::Layer::Handle> layer_set(selected_list.begin(),selected_list.end());
2839 if(!layer_set.empty())
2842 synfig::TransformStack transform_stack;
2844 rebuild_ducks_layer_(transform_stack, get_canvas(), layer_set);
2848 // Now do the children
2850 synfigapp::SelectionManager::ChildrenList selected_list(get_selection_manager()->get_selected_children());
2851 synfigapp::SelectionManager::ChildrenList::iterator iter;
2852 synfig::TransformStack transform_stack;
2854 if(selected_list.empty())
2861 for(iter=selected_list.begin();iter!=selected_list.end();++iter)
2863 work_area->add_to_ducks(*iter,this,transform_stack);
2867 work_area->refresh_selected_ducks();
2868 work_area->queue_draw_preview();
2872 CanvasView::decrease_low_res_pixel_size()
2874 list<int> sizes = CanvasView::get_pixel_sizes();
2875 int pixel_size = work_area->get_low_res_pixel_size();
2877 for (list<int>::iterator iter = sizes.begin(); iter != sizes.end(); iter++)
2878 if (*iter == pixel_size)
2880 if (iter == sizes.begin())
2881 // we already have the smallest low-res pixels possible - turn off low-res instead
2882 work_area->set_low_resolution_flag(false);
2886 Glib::RefPtr<Gtk::Action> action = action_group->get_action(strprintf("lowres-pixel-%d", *iter));
2887 action->activate(); // to make sure the radiobutton in the menu is updated too
2888 work_area->set_low_resolution_flag(true);
2895 CanvasView::increase_low_res_pixel_size()
2897 list<int> sizes = CanvasView::get_pixel_sizes();
2898 int pixel_size = work_area->get_low_res_pixel_size();
2900 if (!work_area->get_low_resolution_flag())
2902 work_area->set_low_resolution_flag(true);
2906 for (list<int>::iterator iter = sizes.begin(); iter != sizes.end(); iter++)
2907 if (*iter == pixel_size)
2910 if (iter != sizes.end())
2912 Glib::RefPtr<Gtk::Action> action = action_group->get_action(strprintf("lowres-pixel-%d", *iter));
2913 action->activate(); // to make sure the radiobutton in the menu is updated too
2914 work_area->set_low_resolution_flag(true);
2921 CanvasView::on_dirty_preview()
2925 IsWorking is_working(*this);
2927 work_area->queue_render_preview();
2934 assert(get_canvas());
2936 // If we are already busy, don't play!
2937 if(working_depth)return;
2939 // Set us up as working
2940 IsWorking is_working(*this);
2944 time=work_area->get_time(),
2945 endtime=get_canvas()->rend_desc().get_time_end();
2947 // If we are already at the end of time, start over
2949 time=get_canvas()->rend_desc().get_time_start();
2953 work_area->clear_ducks();
2955 for(timer.reset(); time + timer() < endtime;)
2957 //Clamp the time window so we can see the time value as it races across the horizon
2958 bool timewindreset = false;
2960 while( time + timer() > Time(time_window_adjustment().get_sub_upper()) )
2962 time_window_adjustment().set_value(
2964 time_window_adjustment().get_value()+time_window_adjustment().get_page_size()/2,
2965 time_window_adjustment().get_upper()-time_window_adjustment().get_page_size() )
2967 timewindreset = true;
2970 while( time + timer() < Time(time_window_adjustment().get_sub_lower()) )
2972 time_window_adjustment().set_value(
2974 time_window_adjustment().get_value()-time_window_adjustment().get_page_size()/2,
2975 time_window_adjustment().get_lower())
2978 timewindreset = true;
2981 //we need to tell people that the value changed
2982 if(timewindreset) time_window_adjustment().value_changed();
2984 //update actual time to next step
2985 time_adjustment().set_value(time+timer());
2986 time_adjustment().value_changed();
2988 if(!work_area->sync_render_preview())
2991 // wait for the workarea to refresh itself
2992 while (studio::App::events_pending())
2993 studio::App::iteration(false);
2995 if(get_cancel_status())
3003 time_adjustment().set_value(endtime);
3004 time_adjustment().value_changed();
3008 CanvasView::show_tables()
3011 Smach::event_result x(process_event_key(EVENT_TABLES_SHOW));
3012 if(x==Smach::RESULT_OK || x==Smach::RESULT_ACCEPT)
3014 Gtk::IconSize iconsize=Gtk::IconSize::from_name("synfig-small_icon");
3015 treetogglebutton->remove();
3016 treetogglebutton->add(*manage(new Gtk::Image(Gtk::StockID("gtk-go-down"),iconsize)));
3017 treetogglebutton->show_all();
3024 CanvasView::hide_tables()
3027 Smach::event_result x(process_event_key(EVENT_TABLES_HIDE));
3028 if(x==Smach::RESULT_OK || x==Smach::RESULT_ACCEPT)
3030 Gtk::IconSize iconsize=Gtk::IconSize::from_name("synfig-small_icon");
3031 treetogglebutton->remove();
3032 treetogglebutton->add(*manage(new Gtk::Image(Gtk::StockID("gtk-go-up"),iconsize)));
3033 treetogglebutton->show_all();
3040 CanvasView::tables_are_visible()
3042 // return notebook->is_visible();
3047 CanvasView::toggle_tables()
3049 // if(tables_are_visible())
3056 CanvasView::show_timebar()
3059 current_time_widget->show();
3061 //keyframe_tab_child->show();
3063 layer_tree->set_show_timetrack(true);
3065 children_tree->set_show_timetrack(true);
3069 CanvasView::hide_timebar()
3072 current_time_widget->hide();
3073 //keyframe_tab_child->hide();
3075 layer_tree->set_show_timetrack(false);
3077 children_tree->set_show_timetrack(false);
3081 CanvasView::set_sensitive_timebar(bool sensitive)
3083 timebar->set_sensitive(sensitive);
3084 current_time_widget->set_sensitive(sensitive);
3085 //keyframe_tab_child->set_sensitive(sensitive);
3087 layer_tree->set_sensitive(sensitive);
3089 children_tree->set_sensitive(sensitive);
3094 CanvasView::on_waypoint_clicked(synfigapp::ValueDesc value_desc,synfig::Waypoint waypoint,int button)
3096 waypoint_dialog.set_value_desc(value_desc);
3097 waypoint_dialog.set_waypoint(waypoint);
3102 waypoint_dialog.show();
3106 Gtk::Menu* waypoint_menu(manage(new Gtk::Menu()));
3107 waypoint_menu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), waypoint_menu));
3109 waypoint_menu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-jump-to"),
3112 *canvas_interface(),
3113 &synfigapp::CanvasInterface::set_time
3119 waypoint_menu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID(_("Edit Waypoint")),
3126 waypoint_menu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("synfig-duplicate"),
3130 *canvas_interface(),
3131 &synfigapp::CanvasInterface::waypoint_duplicate
3138 waypoint_menu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-delete"),
3142 *canvas_interface(),
3143 &synfigapp::CanvasInterface::waypoint_remove
3150 waypoint_menu->popup(button+1,gtk_get_current_event_time());
3159 CanvasView::on_waypoint_changed()
3161 synfigapp::Action::ParamList param_list;
3162 param_list.add("canvas",get_canvas());
3163 param_list.add("canvas_interface",canvas_interface());
3164 param_list.add("value_node",waypoint_dialog.get_value_desc().get_value_node());
3165 param_list.add("waypoint",waypoint_dialog.get_waypoint());
3166 // param_list.add("time",canvas_interface()->get_time());
3168 get_instance()->process_action("waypoint_set_smart", param_list);
3172 CanvasView::on_waypoint_delete()
3174 synfigapp::Action::ParamList param_list;
3175 param_list.add("canvas",get_canvas());
3176 param_list.add("canvas_interface",canvas_interface());
3177 param_list.add("value_node",waypoint_dialog.get_value_desc().get_value_node());
3178 param_list.add("waypoint",waypoint_dialog.get_waypoint());
3179 // param_list.add("time",canvas_interface()->get_time());
3181 get_instance()->process_action("waypoint_remove", param_list);
3185 CanvasView::on_drop_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int /*x*/, int /*y*/, const Gtk::SelectionData& selection_data_, guint /*info*/, guint time)
3187 // We will make this true once we have a solid drop
3188 bool success(false);
3189 //synfig::info("Dropped data of type \"%s\"",selection_data.get_data_type());
3190 //synfig::info("Dropped data of target \"%s\"",gdk_atom_name(selection_data->target));
3191 //synfig::info("selection=\"%s\"",gdk_atom_name(selection_data->selection));
3193 if ((selection_data_.get_length() >= 0) && (selection_data_.get_format() == 8))
3195 if(synfig::String(selection_data_.get_data_type())=="STRING")do
3197 synfig::String selection_data((gchar *)(selection_data_.get_data()));
3199 Layer::Handle layer(synfig::Layer::create("Text"));
3202 if(!layer->set_param("text",ValueBase(selection_data)))
3205 synfigapp::Action::Handle action(synfigapp::Action::create("layer_add"));
3211 action->set_param("canvas",get_canvas());
3212 action->set_param("canvas_interface",canvas_interface());
3213 action->set_param("new",layer);
3215 if(!get_instance()->perform_action(action))
3218 // Ok, we have successfully imported at least one item.
3220 } while(0); // END of "STRING"
3222 if(synfig::String(selection_data_.get_data_type())=="text/plain")
3224 synfig::String selection_data((gchar *)(selection_data_.get_data()));
3226 // For some reason, GTK hands us a list of URLs separated
3227 // by not only Carriage-Returns, but also Line-Feeds.
3228 // Line-Feeds will mess us up. Remove all the line-feeds.
3229 while(selection_data.find_first_of('\r')!=synfig::String::npos)
3230 selection_data.erase(selection_data.begin()+selection_data.find_first_of('\r'));
3232 std::stringstream stream(selection_data);
3234 //synfigapp::PassiveGrouper group(canvas_interface()->get_instance(),_("Insert Image"));
3237 synfig::String filename,URI;
3238 getline(stream,filename);
3240 // If we don't have a filename, move on.
3241 if(filename.empty())
3244 // Make sure this URL is of the "file://" type.
3245 URI=String(filename.begin(),filename.begin()+sizeof("file://")-1);
3248 synfig::warning("Unknown URI (%s) in \"%s\"",URI.c_str(),filename.c_str());
3252 // Strip the "file://" part from the filename
3253 filename=synfig::String(filename.begin()+sizeof("file://")-1,filename.end());
3255 String ext(filename_extension(filename));
3256 if (ext.size()) ext = ext.substr(1); // skip initial '.'
3258 // If this is a SIF file, then we need to do things slightly differently
3261 if(work_area->load_sketch(filename))
3264 work_area->queue_draw();
3269 if(canvas_interface()->import(filename))
3275 } // END of "text/plain"
3278 ui_interface_->error("Drop failed: bad selection data");
3281 context->drag_finish(success, false, time);
3285 CanvasView::on_keyframe_add_pressed()
3287 synfigapp::Action::Handle action(synfigapp::Action::create("keyframe_add"));
3291 ui_interface_->error("I am unable to find the appropriate action");
3295 action->set_param("canvas",get_canvas());
3296 action->set_param("canvas_interface",canvas_interface());
3297 action->set_param("keyframe",Keyframe(get_time()));
3299 canvas_interface()->get_instance()->perform_action(action);
3303 CanvasView::on_keyframe_duplicate_pressed()
3305 const KeyframeTreeStore::Model model;
3306 const Gtk::TreeRow row(*keyframe_tree->get_selection()->get_selected());
3310 ui_interface_->error("I am unable to duplicate the keyframe");
3313 keyframe=row[model.keyframe];
3315 synfigapp::Action::Handle action(synfigapp::Action::create("keyframe_duplicate"));
3319 ui_interface_->error("I am unable to find the appropriate action");
3323 action->set_param("canvas",get_canvas());
3324 action->set_param("canvas_interface",canvas_interface());
3325 action->set_param("keyframe",keyframe);
3326 action->set_param("time",get_time());
3328 canvas_interface()->get_instance()->perform_action(action);
3332 CanvasView::on_keyframe_remove_pressed()
3334 const KeyframeTreeStore::Model model;
3335 const Gtk::TreeRow row(*keyframe_tree->get_selection()->get_selected());
3339 ui_interface_->error("I am unable to remove the keyframe");
3342 keyframe=row[model.keyframe];
3344 synfigapp::Action::Handle action(synfigapp::Action::create("keyframe_remove"));
3348 ui_interface_->error("I am unable to find the appropriate action");
3352 action->set_param("canvas",get_canvas());
3353 action->set_param("canvas_interface",canvas_interface());
3354 action->set_param("keyframe",keyframe);
3356 canvas_interface()->get_instance()->perform_action(action);
3361 CanvasView::toggle_duck_mask(Duckmatic::Type type)
3363 bool is_currently_on(work_area->get_type_mask()&type);
3367 case Duck::TYPE_POSITION:
3368 if(duck_mask_position)
3369 duck_mask_position->set_active(!is_currently_on);
3372 case Duck::TYPE_VERTEX:
3373 if(duck_mask_vertex)
3374 duck_mask_vertex->set_active(!is_currently_on);
3377 case Duck::TYPE_TANGENT:
3378 if(duck_mask_tangent)
3379 duck_mask_tangent->set_active(!is_currently_on);
3382 case Duck::TYPE_RADIUS:
3383 if(duck_mask_radius)
3384 duck_mask_radius->set_active(!is_currently_on);
3387 case Duck::TYPE_WIDTH:
3389 duck_mask_width->set_active(!is_currently_on);
3392 case Duck::TYPE_ANGLE:
3394 duck_mask_angle->set_active(!is_currently_on);
3398 synfig::warning("CanvasView::toggle_duck_mask():Unknown duck type!");
3403 work_area->set_type_mask(work_area->get_type_mask()-type);
3405 work_area->set_type_mask(work_area->get_type_mask()|type);
3407 work_area->queue_draw();
3412 CanvasView::image_import()
3414 // String filename(dirname(get_canvas()->get_file_name()));
3415 String filename("*.*");
3416 if(App::dialog_open_file(_("Import Image"), filename, IMAGE_DIR_PREFERENCE))
3417 canvas_interface()->import(filename);
3421 CanvasView::process_event_key(EventKey x)
3423 return smach_.process_event(x);
3427 CanvasView::on_input_device_changed(GdkDevice* device)
3431 get_smach().egress();
3435 synfigapp::InputDevice::Handle input_device;
3436 input_device=synfigapp::Main::select_input_device(device->name);
3437 App::toolbox->change_state(input_device->get_state());
3438 process_event_key(EVENT_INPUT_DEVICE_CHANGED);
3442 CanvasView::on_preview_option()
3444 Dialog_PreviewOptions *po = dynamic_cast<Dialog_PreviewOptions *>(get_ext_widget("prevoptions"));
3446 Canvas::Handle canv = get_canvas();
3450 RendDesc &r = canv->rend_desc();
3451 if(r.get_frame_rate())
3453 float rate = 1/r.get_frame_rate();
3454 float beg = r.get_time_start() + r.get_frame_start()*rate;
3455 float end = r.get_time_start() + r.get_frame_end()*rate;
3459 po = new Dialog_PreviewOptions;
3460 po->set_zoom(work_area->get_zoom()/2);
3461 po->set_fps(r.get_frame_rate()/2);
3462 po->set_begintime(beg);
3463 po->set_begin_override(false);
3464 po->set_endtime(end);
3465 po->set_end_override(false);
3467 set_ext_widget("prevoptions",po);
3469 /*po->set_zoom(work_area->get_zoom()/2);
3470 po->set_fps(r.get_frame_rate()/2);
3471 po->set_begintime(beg);
3472 po->set_begin_override(false);
3473 po->set_endtime(end);
3474 po->set_end_override(false);*/
3476 po->set_global_fps(r.get_frame_rate());
3477 po->signal_finish().connect(sigc::mem_fun(*this,&CanvasView::on_preview_create));
3484 CanvasView::on_preview_create(const PreviewInfo &info)
3486 //set all the options
3487 etl::handle<Preview> prev = new Preview;
3489 prev->set_canvasview(this);
3490 prev->set_zoom(info.zoom);
3491 prev->set_fps(info.fps);
3492 prev->set_overbegin(info.overbegin);
3493 prev->set_begintime(info.begintime);
3494 prev->set_overend(info.overend);
3495 prev->set_endtime(info.endtime);
3496 prev->set_quality(work_area->get_quality());
3501 Dialog_Preview *pd = preview_dialog.get();
3504 pd->set_default_size(700,510);
3505 pd->set_preview(prev.get());
3510 CanvasView::on_audio_option()
3512 synfig::warning("Launching Audio Options");
3513 sound_dialog->set_global_fps(get_canvas()->rend_desc().get_frame_rate());
3514 sound_dialog->present();
3518 CanvasView::on_audio_file_change(const std::string &f)
3520 //save in meta data - always even when not valid...
3521 canvas_interface()->set_meta_data("audiofile",f);
3525 CanvasView::on_audio_offset_change(const synfig::Time &t)
3527 canvas_interface()->set_meta_data("audiooffset",t.get_string());
3531 CanvasView::on_audio_file_notify()
3533 std::string file(get_canvas()->get_meta_data("audiofile"));
3534 if(!file.c_str()) return;
3536 if(!audio->load(file,dirname(get_canvas()->get_file_name())+string("/")))
3538 if(file != "") synfig::warning("Could not load the file: %s", file.c_str());
3539 get_canvas()->erase_meta_data("audiofile");
3541 disp_audio->set_profile(etl::handle<AudioProfile>());
3544 //save in canvasview
3545 synfig::warning("Getting the profile of the music stuff");
3547 //profile specific stuff for the preview widget
3548 //similar for other attachments
3549 Dialog_Preview *pd = preview_dialog.get();
3550 pd->get_widget().set_audio(audio);
3552 handle<AudioProfile> prof = audio->get_profile();
3556 synfig::warning("Agh, I couldn't build the profile captain!");
3558 pd->get_widget().set_audioprofile(prof);
3560 disp_audio->set_profile(audio->get_profile());
3563 synfig::warning("successfully set the profiles and stuff");
3565 disp_audio->queue_draw();
3569 CanvasView::on_audio_offset_notify()
3571 Time t(get_canvas()->get_meta_data("audiooffset"),get_canvas()->rend_desc().get_frame_rate());
3572 audio->set_offset(t);
3573 sound_dialog->set_offset(t);
3574 disp_audio->queue_draw();
3576 // synfig::info("CanvasView::on_audio_offset_notify(): offset time set to %s",t.get_string(get_canvas()->rend_desc().get_frame_rate()).c_str());
3580 CanvasView::play_audio(float t)
3584 synfig::info("Playing audio at %f s",t);
3590 CanvasView::stop_audio()
3599 CanvasView::on_audio_scrub()
3607 Glib::RefPtr<Glib::ObjectBase>
3608 CanvasView::get_ref_obj(const synfig::String& x)
3610 return ref_obj_book_[x];
3613 Glib::RefPtr<const Glib::ObjectBase>
3614 CanvasView::get_ref_obj(const synfig::String& x)const
3616 return ref_obj_book_.find(x)->second;
3620 CanvasView::set_ref_obj(const synfig::String& x, Glib::RefPtr<Glib::ObjectBase> y)
3625 Glib::RefPtr<Gtk::TreeModel>
3626 CanvasView::get_tree_model(const synfig::String& x)
3628 return Glib::RefPtr<Gtk::TreeModel>::cast_dynamic(ref_obj_book_["_tree_model_"+x]);
3631 Glib::RefPtr<const Gtk::TreeModel>
3632 CanvasView::get_tree_model(const synfig::String& x)const
3634 return Glib::RefPtr<Gtk::TreeModel>::cast_dynamic(ref_obj_book_.find("_tree_model_"+x)->second);
3638 CanvasView::set_tree_model(const synfig::String& x, Glib::RefPtr<Gtk::TreeModel> y)
3640 ref_obj_book_["_tree_model_"+x]=Glib::RefPtr<Glib::ObjectBase>::cast_static(y);
3644 CanvasView::get_ext_widget(const synfig::String& x)
3646 return ext_widget_book_[x];
3650 CanvasView::set_ext_widget(const synfig::String& x, Gtk::Widget* y)
3652 ext_widget_book_[x]=y;
3655 layer_tree=dynamic_cast<LayerTree*>(y);
3657 layer_tree->get_selection()->signal_changed().connect(SLOT_EVENT(EVENT_LAYER_SELECTION_CHANGED));
3658 layer_tree->get_selection()->signal_changed().connect(SLOT_EVENT(EVENT_REFRESH_DUCKS));
3659 layer_tree->signal_layer_user_click().connect(sigc::mem_fun(*this, &studio::CanvasView::on_layer_user_click));
3660 layer_tree->signal_param_user_click().connect(sigc::mem_fun(*this, &studio::CanvasView::on_children_user_click));
3661 layer_tree->signal_waypoint_clicked().connect(sigc::mem_fun(*this, &studio::CanvasView::on_waypoint_clicked));
3665 children_tree=dynamic_cast<ChildrenTree*>(y);
3666 if(children_tree)children_tree->signal_user_click().connect(sigc::mem_fun(*this, &studio::CanvasView::on_children_user_click));
3667 if(children_tree)children_tree->signal_waypoint_clicked().connect(sigc::mem_fun(*this, &studio::CanvasView::on_waypoint_clicked));
3668 if(children_tree)children_tree->get_selection()->signal_changed().connect(SLOT_EVENT(EVENT_REFRESH_DUCKS));
3671 keyframe_tree=dynamic_cast<KeyframeTree*>(y);
3675 CanvasView::on_delete_event(GdkEventAny* event __attribute__ ((unused)))
3679 //! \todo This causes the window to be deleted straight away - but what if we prompt 'save?' and the user cancels?
3680 // Is there ever any need to pass on the delete event to the window here?
3681 // if(event) return Gtk::Window::on_delete_event(event);