1 /* === S I N F G =========================================================== */
3 ** \brief Template Header
5 ** $Id: canvasview.h,v 1.2 2005/01/13 18:37:30 darco Exp $
8 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
10 ** This software and associated documentation
11 ** are CONFIDENTIAL and PROPRIETARY property of
12 ** the above-mentioned copyright holder.
14 ** You may not copy, print, publish, or in any
15 ** other way distribute this software without
16 ** a prior written agreement with
17 ** the copyright holder.
20 /* ========================================================================= */
22 /* === S T A R T =========================================================== */
24 #ifndef __SINFG_STUDIO_GTKMM_CANVASVIEW_H
25 #define __SINFG_STUDIO_GTKMM_CANVASVIEW_H
27 /* === H E A D E R S ======================================================= */
29 #include <gtkmm/window.h>
30 #include <gtkmm/image.h>
31 #include <gtkmm/tooltips.h>
32 #include <gtkmm/table.h>
33 #include <gtkmm/statusbar.h>
34 #include <gtkmm/progressbar.h>
35 #include <gtkmm/button.h>
36 #include <gtkmm/menu.h>
37 #include <gtkmm/treeview.h>
38 #include <gtkmm/treestore.h>
39 #include <gtkmm/scrolledwindow.h>
40 #include <gtkmm/notebook.h>
41 #include <gdkmm/device.h>
43 #include <sinfgapp/canvasinterface.h>
44 #include <sinfgapp/selectionmanager.h>
46 #include <sinfg/canvas.h>
47 #include <sinfg/string.h>
48 #include <sinfg/time.h>
51 #include "canvasproperties.h"
52 #include "canvasoptions.h"
54 #include "cellrenderer_timetrack.h"
57 #include "layertreestore.h"
58 #include "layertree.h"
59 #include "childrentreestore.h"
60 #include "childrentree.h"
61 #include "keyframetreestore.h"
62 #include "keyframetree.h"
64 #include "dialog_waypoint.h"
65 #include "dialog_keyframe.h"
67 #include "duckmatic.h"
68 #include <gtkmm/scale.h>
70 #include <gtkmm/uimanager.h>
77 #include <gtkmm/toggleaction.h>
78 #include <gtkmm/radioaction.h>
79 #include <sinfg/rect.h>
81 #include "adjust_window.h"
83 #include <sinfg/transform.h>
85 /* === M A C R O S ========================================================= */
87 #ifndef DEBUGPOINT_CLASS
89 #define DEBUGPOINT_CLASS(x) struct debugpointclass_ ## x { debugpointclass_ ## x () { DEBUGPOINT(); } ~debugpointclass_ ## x () { DEBUGPOINT(); } } badfthguae_ ## x ;
91 #define DEBUGPOINT_CLASS(x)
95 /* === T Y P E D E F S ===================================================== */
97 /* === C L A S S E S & S T R U C T S ======================================= */
101 class CanvasViewUIInterface;
102 class CanvasViewSelectionManager;
104 class CellRenderer_TimeTrack;
105 class CellRenderer_ValueBase;
106 class UniversalScrubber;
113 class AudioContainer;
116 class Widget_Timeslider;
119 class Dialog_SoundSelect;
120 class Dialog_Preview;
122 class sinfg::TransformStack;
125 class Dock_Keyframes;
127 class CanvasView : public Gtk::Window, public etl::shared_object
129 friend class UniversalScrubber;
130 friend class Dock_Layers;
131 friend class Dock_Children;
132 friend class Dock_Keyframes;
134 friend class CanvasViewUIInterface;
135 friend class CanvasViewSelectionManager;
137 friend class Duckmatic;
140 -- ** -- P U B L I C T Y P E S ---------------------------------------------
145 typedef etl::handle<CanvasView> Handle;
147 typedef etl::handle<const CanvasView> ConstHandle;
149 typedef etl::loose_handle<CanvasView> LooseHandle;
151 typedef LayerTreeStore::Model LayerTreeModel;
153 typedef ChildrenTreeStore::Model ChildrenTreeModel;
155 //! Create an instance of this class whenever doing a longer task.
156 /*! Make sure that you check the bool value of this class occasionaly
157 ** to make sure the action has not been canceled. */
160 CanvasView &canvas_view_;
163 IsWorking(CanvasView &canvas_view_);
165 operator bool()const;
167 friend class IsWorking;
169 typedef sinfgapp::CanvasInterface::Mode Mode;
172 -- ** -- P R I V A T E D A T A ---------------------------------------------
176 std::auto_ptr<WorkArea> work_area;
178 WorkArea* get_work_area() { return work_area.get(); }
181 sinfg::TransformStack curr_transform_stack;
182 bool curr_transform_stack_set;
193 etl::loose_handle<Instance> instance_;
194 etl::handle<sinfgapp::CanvasInterface> canvas_interface_;
198 //! Sound and information to play it
199 etl::handle<AudioContainer> audio;
200 studio::Widget_Sound *disp_audio; //should this be put into thing too?
202 SigC::Connection playcon;
203 SigC::Connection stopcon;
205 std::auto_ptr<UniversalScrubber> universal_scrubber;
207 //! Tooltip controler
208 Gtk::Tooltips tooltips;
212 //! TreeModel for the layers
213 LayerTreeModel layer_tree_model;
215 //! TreeModel for the the children
216 ChildrenTreeModel children_tree_model;
218 //Glib::RefPtr<LayerTreeStore> layer_tree_store_;
220 //Glib::RefPtr<ChildrenTreeStore> children_tree_store_;
222 //Glib::RefPtr<KeyframeTreeStore> keyframe_tree_store_;
226 //std::map<sinfg::String,Glib::RefPtr<Gtk::TreeModel> > tree_model_book_;
227 std::map<sinfg::String,Glib::RefPtr<Glib::ObjectBase> > ref_obj_book_;
228 std::map<sinfg::String,Gtk::Widget*> ext_widget_book_;
231 //! The time adjustment's scope is defined by the time_window adjustment
232 Gtk::Adjustment time_adjustment_;
234 //! The time_window adjustment governs the position of the time window on the whole time line
235 //Gtk::Adjustment time_window_adjustment_;
236 studio::Adjust_Window time_window_adjustment_;
239 LayerTree *layer_tree;
241 ChildrenTree *children_tree;
243 KeyframeTree *keyframe_tree;
245 Gtk::Widget *keyframe_tab_child;
247 Gtk::ProgressBar *progressbar;
248 Gtk::Statusbar *statusbar;
250 Gtk::TreeRow children_canvas_row;
251 Gtk::TreeRow children_valuenode_row;
253 Gtk::Button *stopbutton;
254 Gtk::Button *refreshbutton;
255 Gtk::Button *treetogglebutton;
256 Gtk::Notebook *notebook;
257 Gtk::Widget *timebar;
259 Widget_Time *current_time_widget;
260 void on_current_time_widget_changed();
262 std::auto_ptr<Widget_Timeslider> timeslider;
264 std::list<sigc::connection> duck_changed_connections;
268 Gtk::Button *animatebutton;
269 Gtk::Button *keyframebutton;
271 /* DEBUGPOINT_CLASS(8);
273 Gtk::Menu duckmaskmenu;
274 DEBUGPOINT_CLASS(77);
275 Gtk::Menu qualitymenu;
279 DEBUGPOINT_CLASS(777);
281 DEBUGPOINT_CLASS(71);
282 Gtk::Menu canvasmenu;
283 DEBUGPOINT_CLASS(73);
287 DEBUGPOINT_CLASS(74);
288 Gtk::Menu newlayermenu;
289 DEBUGPOINT_CLASS(76);
292 DEBUGPOINT_CLASS(99);
293 Gtk::Menu keyframemenu;
300 Gtk::CheckMenuItem* duck_mask_position;
301 Gtk::CheckMenuItem* duck_mask_vertex;
302 Gtk::CheckMenuItem* duck_mask_tangent;
303 Gtk::CheckMenuItem* duck_mask_radius;
304 Gtk::CheckMenuItem* duck_mask_width;
305 Gtk::CheckMenuItem* duck_mask_angle;
310 Glib::RefPtr<Gtk::ToggleAction> duck_mask_position;
311 Glib::RefPtr<Gtk::ToggleAction> duck_mask_vertex;
312 Glib::RefPtr<Gtk::ToggleAction> duck_mask_tangent;
313 Glib::RefPtr<Gtk::ToggleAction> duck_mask_radius;
314 Glib::RefPtr<Gtk::ToggleAction> duck_mask_width;
315 Glib::RefPtr<Gtk::ToggleAction> duck_mask_angle;
317 Gtk::RadioButtonGroup quality_group;
319 Glib::RefPtr<Gtk::ActionGroup> action_group;
322 etl::handle<sinfgapp::UIInterface> ui_interface_;
323 etl::handle<sinfgapp::SelectionManager> selection_manager_;
327 sigc::signal<void> signal_deleted_;
329 bool rebuild_ducks_queued;
330 sigc::connection queue_rebuild_ducks_connection;
333 -- ** -- P U B L I C D A T A -----------------------------------------------
337 void queue_rebuild_ducks();
338 sigc::signal<void>& signal_deleted() { return signal_deleted_; }
342 bool duck_refresh_flag;
343 bool duck_refresh_needed;
345 //! This is for the IsWorking class.
352 -- ** -- D I A L O G S -------------------------------------------------------
357 CanvasProperties canvas_properties;
358 CanvasOptions canvas_options;
359 RenderSettings render_settings;
360 Dialog_Waypoint waypoint_dialog;
361 Dialog_Keyframe keyframe_dialog;
363 std::auto_ptr<Dialog_Preview> preview_dialog;
364 //std::auto_ptr<Dialog_PreviewOptions> previewoption_dialog;
365 std::auto_ptr<Dialog_SoundSelect> sound_dialog;
368 -- ** -- P R I V A T E M E T H O D S ---------------------------------------
373 // Constructor is private to force the use of the "create()" constructor
374 CanvasView(etl::loose_handle<Instance> instance,etl::handle<sinfgapp::CanvasInterface> canvas_interface);
376 //! Constructor Helper
377 Gtk::Widget* create_layer_tree();
379 //! Constructor Helper
380 Gtk::Widget* create_children_tree();
382 //! Constructor Helper
383 Gtk::Widget* create_keyframe_tree();
385 //! Constructor Helper
386 Gtk::Widget* create_status_bar();
388 //! Constructor Helper - Initializes all of the menus
391 bool duck_change_param(const sinfg::Point &value,sinfg::Layer::Handle layer, sinfg::String param_name);
393 void refresh_time_window();
395 void time_was_changed();
397 void refresh_rend_desc();
399 void toggle_duck_mask(Duckmatic::Type type);
401 Gtk::Widget *create_work_area();
403 Gtk::Widget *create_time_bar();
407 void popup_param_menu_bezier(float location, sinfgapp::ValueDesc value_desc)
408 { popup_param_menu(value_desc,location); }
410 void popup_param_menu(sinfgapp::ValueDesc value_desc, float location=0);
413 void workarea_layer_selected(sinfg::Layer::Handle layer);
415 void selected_layer_color_set(sinfg::Color color);
419 void register_layer_type(sinfg::Layer::Book::value_type &lyr,std::map<sinfg::String,Gtk::Menu*>*);
421 //! Rebuilds the "new layer" menu
422 void build_new_layer_menu(Gtk::Menu &menu);
424 void rebuild_ducks_layer_(sinfg::TransformStack& transform_stack, sinfg::Canvas::Handle canvas, std::set<sinfg::Layer::Handle>& selected_list);
427 -- ** -- P U B L I C M E T H O D S -----------------------------------------
431 const sinfg::TransformStack& get_curr_transform_stack()const { return curr_transform_stack; }
433 const sinfg::Rect& get_bbox()const { return bbox; }
435 Glib::RefPtr<Glib::ObjectBase> get_ref_obj(const sinfg::String& x);
436 Glib::RefPtr<const Glib::ObjectBase> get_ref_obj(const sinfg::String& x)const;
437 void set_ref_obj(const sinfg::String& x, Glib::RefPtr<Glib::ObjectBase> y);
439 Glib::RefPtr<Gtk::TreeModel> get_tree_model(const sinfg::String& x);
440 Glib::RefPtr<const Gtk::TreeModel> get_tree_model(const sinfg::String& x)const;
441 void set_tree_model(const sinfg::String& x, Glib::RefPtr<Gtk::TreeModel> y);
443 Gtk::Widget* get_ext_widget(const sinfg::String& x);
444 void set_ext_widget(const sinfg::String& x, Gtk::Widget* y);
446 //std::map<sinfg::String,Gtk::Widget*>& tree_view_book() { return tree_view_book_; }
447 //std::map<sinfg::String,Gtk::Widget*>& ext_widget_book() { return tree_view_book_; }
449 void popup_main_menu();
451 Smach& get_smach() { return smach_; }
453 const Smach& get_smach()const { return smach_; }
455 Smach::event_result process_event_key(EventKey x);
457 void popup_layer_menu(sinfg::Layer::Handle layer);
459 virtual ~CanvasView();
461 void set_mode(Mode x) { canvas_interface()->set_mode(x); }
463 Mode get_mode()const { return canvas_interface()->get_mode(); }
465 Gtk::Adjustment &time_adjustment() { return time_adjustment_; }
467 const Gtk::Adjustment &time_adjustment()const { return time_adjustment_; }
469 studio::Adjust_Window &time_window_adjustment() { return time_window_adjustment_; }
471 const studio::Adjust_Window &time_window_adjustment()const { return time_window_adjustment_; }
473 etl::handle<sinfgapp::UIInterface> get_ui_interface() { return ui_interface_;}
475 etl::handle<sinfgapp::SelectionManager> get_selection_manager() { return selection_manager_; }
477 Glib::RefPtr<Gtk::TreeModel> layer_tree_store() { return get_tree_model("layers"); }
479 Glib::RefPtr<const Gtk::TreeModel> layer_tree_store()const { return get_tree_model("layers"); }
481 Glib::RefPtr<Gtk::TreeModel> children_tree_store() { return get_tree_model("children"); }
483 Glib::RefPtr<const Gtk::TreeModel> children_tree_store()const { return get_tree_model("children"); }
485 Glib::RefPtr<Gtk::TreeModel> keyframe_tree_store() { return get_tree_model("keyframes"); }
487 Glib::RefPtr<const Gtk::TreeModel> keyframe_tree_store()const { return get_tree_model("keyframes"); }
489 void set_time(sinfg::Time t) { canvas_interface_->set_time(t); }
491 sinfg::Time get_time() { return canvas_interface_->get_time(); }
493 etl::handle<sinfg::Canvas> get_canvas()const { return canvas_interface_->get_canvas(); }
495 etl::handle<Instance> get_instance()const { return instance_; }
497 etl::handle<sinfgapp::CanvasInterface> canvas_interface() { return canvas_interface_; }
499 etl::handle<const sinfgapp::CanvasInterface> canvas_interface()const { return canvas_interface_; }
501 void add_actions_to_menu(Gtk::Menu *menu, const sinfgapp::Action::ParamList ¶m_list, sinfgapp::Action::Category category=sinfgapp::Action::CATEGORY_ALL)const;
503 //! Updates the title of the window
506 //! Closes this canvas view
509 //! Stops the currently executing action
510 /*! \see get_cancel_status(), reset_cancel_status(), IsWorking */
511 void stop() { cancel=true; }
513 //! Returns the cancel status
514 /*! \see stop(), reset_cancel_status(), IsWorking */
515 bool get_cancel_status()const { return cancel; }
517 //! Resets the cancel status
518 /*! \see stop(), get_cancel_status(), IsWorking */
519 void reset_cancel_status() { cancel=false; }
521 void new_child_canvas();
523 //! Rebuilds layer_tree_store_ from the Canvas. Maintains selected items.
524 void rebuild_tables();
526 //! Builds layer_tree_store_ from the Canvas. Does not maintain selected items.
529 //! Refreshes the data for the tables
530 void refresh_tables();
532 //void rebuild_layer_table();
533 //void build_layer_table();
534 //void refresh_layer_table();
536 // void rebuild_canvas_table();
537 // void build_canvas_table();
538 // void refresh_canvas_table();
540 // void rebuild_valuenode_table();
541 // void build_valuenode_table();
542 // void refresh_valuenode_table();
545 void rebuild_ducks();
547 //bool add_to_ducks(sinfgapp::ValueDesc value_desc, sinfg::ParamDesc *param_desc=NULL);
549 //! Starts "playing" the animation in real-time
552 //! Shows the tables (Layer/Children)
555 //! Hides the tables (Layer/Children)
558 //! Toggles the tables
559 void toggle_tables();
561 //! Gets the table status
562 bool tables_are_visible();
564 //! Shows the time bar
567 //! Hides the time bar
570 void do_rotoscope_bline();
574 void do_rotoscope_poly();
579 void time_zoom_out();
581 void add_layer(sinfg::String x);
583 void show_keyframe_dialog();
585 void play_audio(float t);
590 void on_waypoint_clicked(sinfgapp::ValueDesc,sinfg::Waypoint, int button);
592 void preview_option() {on_preview_option();}
597 -- ** -- S I G N A L T E R M I N A L S -------------------------------------
602 void on_unselect_layers();
604 void on_input_device_changed(GdkDevice*);
606 virtual void on_hide();
608 virtual bool on_focus_in_event(GdkEventFocus*);
609 virtual bool on_focus_out_event(GdkEventFocus*);
611 //bool on_children_tree_event(GdkEvent *event);
613 bool on_keyframe_tree_event(GdkEvent *event);
615 //void on_children_edited_value(const Glib::ustring&path_string,sinfg::ValueBase value);
617 void on_dirty_preview();
619 bool on_children_user_click(int, Gtk::TreeRow, ChildrenTree::ColumnID);
621 bool on_layer_user_click(int, Gtk::TreeRow, LayerTree::ColumnID);
623 // void on_layer_toggle(const Glib::ustring& path_string, Gtk::TreeModelColumn<bool> column);
625 void on_mode_changed(sinfgapp::CanvasInterface::Mode mode);
627 // void on_layer_waypoint_clicked(const Glib::ustring &, sinfg::ValueNode_Animated::WaypointList::iterator);
629 //void on_children_waypoint_clicked(const Glib::ustring &, sinfg::ValueNode_Animated::WaypointList::iterator);
631 void on_waypoint_changed();
633 void on_waypoint_delete();
635 void on_refresh_pressed();
637 void on_id_changed();
639 void on_time_changed();
642 void on_layer_raise_pressed();
643 void on_layer_lower_pressed();
644 void on_layer_duplicate_pressed();
645 void on_layer_delete_pressed();
648 void on_keyframe_add_pressed();
650 void on_keyframe_duplicate_pressed();
652 void on_keyframe_remove_pressed();
654 void on_animate_button_pressed();
656 void on_keyframe_button_pressed();
658 void on_preview_option();
659 void on_preview_create(const PreviewInfo &);
661 void on_audio_option();
662 void on_audio_file_change(const std::string &f);
663 void on_audio_offset_change(const sinfg::Time &t);
665 void on_audio_file_notify();
666 void on_audio_offset_notify();
668 bool on_duck_changed(const sinfg::Point &value,const sinfgapp::ValueDesc& value_desc);
670 void on_layer_toggle(sinfg::Layer::Handle);
672 void on_edited_value(sinfgapp::ValueDesc,sinfg::ValueBase);
674 //void on_waypoint_clicked(sinfgapp::ValueDesc,sinfg::ValueNode_Animated::WaypointList::iterator, int button);
676 void on_drop_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& selection_data, guint info, guint time);
678 //void on_audio_play();
679 bool on_audio_scrub();
682 bool on_delete_event(GdkEventAny* event);
685 -- ** -- S T A T I C P U B L I C M E T H O D S ---------------------------
690 static etl::handle<studio::CanvasView> create(etl::loose_handle<Instance> instance,etl::handle<sinfg::Canvas> canvas);
691 }; // END of class CanvasView
693 }; // END of namespace studio
695 /* === E N D =============================================================== */