Add my copyright to files I've modified.
[synfig.git] / synfig-studio / trunk / src / gtkmm / canvasview.cpp
index 4a631a2..1ab07b1 100644 (file)
@@ -6,6 +6,7 @@
 **
 **     \legal
 **     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007 Chris Moore
 **
 **     This package is free software; you can redistribute it and/or
 **     modify it under the terms of the GNU General Public License as
 #include <gtk/gtktreestore.h>
 #include <gtk/gtkversion.h>
 
+#include <synfig/valuenode_reference.h>
+#include <synfig/valuenode_subtract.h>
+#include <synfig/valuenode_linear.h>
+#include <synfig/valuenode_timedswap.h>
+#include <synfig/valuenode_scale.h>
 #include <synfig/valuenode_dynamiclist.h>
+#include <synfig/valuenode_twotone.h>
+#include <synfig/valuenode_stripes.h>
 #include <synfig/layer.h>
 
 #include <synfigapp/uimanager.h>
 #include <synfigapp/canvasinterface.h>
 #include <synfigapp/selectionmanager.h>
+//#include <synfigapp/action_setwaypoint.h>
+//#include <synfigapp/action_deletewaypoint.h>
 
 #include <sigc++/retype_return.h>
 #include <sigc++/retype.h>
+//#include <sigc++/hide.h>
 
 #include "canvasview.h"
 #include "instance.h"
 #include "app.h"
+#include "cellrenderer_value.h"
 #include "cellrenderer_timetrack.h"
+#include "workarea.h"
+#include "dialog_color.h"
 #include "eventkey.h"
 
+#include "state_polygon.h"
+#include "state_bline.h"
+#include "state_normal.h"
+#include "state_eyedrop.h"
+#include "state_draw.h"
+
+#include "ducktransform_scale.h"
+#include "ducktransform_translate.h"
+#include "ducktransform_rotate.h"
+
+#include "event_mouse.h"
+#include "event_layerclick.h"
+
+#include "toolbox.h"
+
+#include "dialog_preview.h"
+#include "dialog_soundselect.h"
+
+#include "preview.h"
+#include "audiocontainer.h"
 #include "widget_timeslider.h"
 
+#include <synfigapp/main.h>
+#include <synfigapp/inputdevice.h>
+
 #endif
 
 /* === U S I N G =========================================================== */
@@ -410,7 +447,7 @@ public:
        {
 //             assert(view->layer_tree);
 
-               if(!view->layer_tree) { DEBUGPOINT(); synfig::error("canvas_view.layer_tree not defined!?"); return LayerList(); }
+               if(!view->layer_tree) { DEBUGPOINT(); synfig::error("%s:%d canvas_view.layer_tree not defined!?", __FILE__, __LINE__); return LayerList(); }
                return view->layer_tree->get_selected_layers();
        }
 
@@ -419,7 +456,7 @@ public:
        {
 //             assert(view->layer_tree);
 
-               if(!view->layer_tree) { DEBUGPOINT(); synfig::error("canvas_view.layer_tree not defined!?"); return 0; }
+               if(!view->layer_tree) { DEBUGPOINT(); synfig::error("%s:%d canvas_view.layer_tree not defined!?", __FILE__, __LINE__); return 0; }
                return view->layer_tree->get_selected_layer();
        }
 
@@ -428,7 +465,7 @@ public:
        {
 //             assert(view->layer_tree);
 
-               if(!view->layer_tree) { DEBUGPOINT(); synfig::error("canvas_view.layer_tree not defined!?"); return; }
+               if(!view->layer_tree) { DEBUGPOINT(); synfig::error("%s:%d canvas_view.layer_tree not defined!?", __FILE__, __LINE__); return; }
                view->layer_tree->select_layers(layer_list);
                //view->get_smach().process_event(EVENT_REFRESH_DUCKS);
 
@@ -517,13 +554,13 @@ public:
        }
 
        //! Sets which value_nodes should be selected
-       virtual void set_selected_children(const ChildrenList &children_list)
+       virtual void set_selected_children(const ChildrenList &/*children_list*/)
        {
                return;
        }
 
        //! Sets which value_node should be selected. Empty handle if none.
-       virtual void set_selected_child(const ChildrenList::value_type &child)
+       virtual void set_selected_child(const ChildrenList::value_type &/*child*/)
        {
                return;
        }
@@ -574,12 +611,12 @@ public:
                return get_selected_layer_parameters().front();
        }
 
-       void set_selected_layer_parameters(const LayerParamList &layer_param_list)
+       void set_selected_layer_parameters(const LayerParamList &/*layer_param_list*/)
        {
                return;
        }
 
-       void set_selected_layer_param(const LayerParam &layer_param)
+       void set_selected_layer_param(const LayerParam &/*layer_param*/)
        {
                return;
        }
@@ -760,6 +797,13 @@ CanvasView::CanvasView(etl::loose_handle<Instance> instance,etl::handle<synfigap
        int h=get_canvas()->rend_desc().get_h()+70;
        while(w>700 || h>600)
        {
+               // Minor hack:
+               //   zoom_out() =>
+               //         WorkArea::async_update_preview() =>
+               //           WorkArea::set_zoom(float) =>
+               //                 WorkArea::async_update_preview() =>
+               //                       desc.set_time(cur_time), where cur_time isn't initialised
+               work_area->set_time(0);
                work_area->zoom_out();
                w=round_to_int(get_canvas()->rend_desc().get_w()*work_area->get_zoom()+70);
                h=round_to_int(get_canvas()->rend_desc().get_h()*work_area->get_zoom()+70);
@@ -869,6 +913,10 @@ CanvasView::~CanvasView()
 
        hide();
 
+       // don't be calling on_dirty_preview once this object has been deleted;
+       // this was causing a crash before
+       canvas_interface()->signal_dirty_preview().clear();
+
        synfig::info("CanvasView:~CanvasView(): Destructor Finished");
 }
 
@@ -1218,7 +1266,10 @@ CanvasView::init_menus()
                {
                        Glib::RefPtr<Gtk::RadioAction> action(Gtk::RadioAction::create(quality_group,strprintf("quality-%02d",i), strprintf("Set Quality to %d",i)));
                        if(i==10)
-                               action->property_value()=10;
+                       {
+                               action->set_active();
+                               work_area->set_quality(i);
+                       }
                        action_group->add( action,
                                sigc::bind(
                                        sigc::mem_fun(*work_area, &studio::WorkArea::set_quality),
@@ -1228,7 +1279,7 @@ CanvasView::init_menus()
                }
        }
 
-       action_group->add( Gtk::Action::create("play", Gtk::StockID("synfig-play")),
+       action_group->add( Gtk::Action::create("play", Gtk::Stock::MEDIA_PLAY),
                sigc::mem_fun(*this, &studio::CanvasView::play)
        );
 
@@ -1536,7 +1587,7 @@ CanvasView::init_menus()
                viewmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Preview Quality"),qualitymenu));
        }
 
-       viewmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("synfig-play"),
+       viewmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::MEDIA_PLAY,
                sigc::mem_fun(*this, &studio::CanvasView::play)));
        viewmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("Flipbook Dialog"),
                sigc::mem_fun(*preview_dialog, &studio::Dialog_Preview::present)));
@@ -1682,7 +1733,7 @@ CanvasView::popup_layer_menu(synfig::Layer::Handle layer)
 
        //parammenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("New Layer"),*newlayers));
 
-       if(layer->get_name()=="paste_canvas")
+       if(layer->get_name()=="PasteCanvas")
        {
                menu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Select All Children"),
                        sigc::bind(
@@ -1701,7 +1752,7 @@ CanvasView::popup_layer_menu(synfig::Layer::Handle layer)
 }
 
 void
-CanvasView::register_layer_type(synfig::Layer::Book::value_type &lyr,std::map<synfig::String,Gtk::Menu*>* category_map)
+CanvasView::register_layer_type(synfig::Layer::Book::value_type &/*lyr*/,std::map<synfig::String,Gtk::Menu*>* /*category_map*/)
 {
 /*     if(lyr.second.category==_("Do Not Use"))
                return;
@@ -1721,7 +1772,7 @@ CanvasView::register_layer_type(synfig::Layer::Book::value_type &lyr,std::map<sy
 }
 
 void
-CanvasView::build_new_layer_menu(Gtk::Menu &menu)
+CanvasView::build_new_layer_menu(Gtk::Menu &/*menu*/)
 {
 /*
        std::map<synfig::String,Gtk::Menu*> category_map;
@@ -2043,7 +2094,7 @@ CanvasView::add_actions_to_menu(Gtk::Menu *menu, const synfigapp::Action::ParamL
 }
 
 bool
-CanvasView::on_layer_user_click(int button, Gtk::TreeRow row, LayerTree::ColumnID column_id)
+CanvasView::on_layer_user_click(int button, Gtk::TreeRow /*row*/, LayerTree::ColumnID /*column_id*/)
 {
        switch(button)
        {
@@ -2110,7 +2161,7 @@ CanvasView::on_layer_user_click(int button, Gtk::TreeRow row, LayerTree::ColumnI
                                build_new_layer_menu(*newlayers);
 
                                parammenu.items().push_back(Gtk::Menu_Helpers::MenuElem("New Layer",*newlayers));
-                               if(!multiple_selected && layer->get_name()=="paste_canvas")
+                               if(!multiple_selected && layer->get_name()=="PasteCanvas")
                                {
                                        parammenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Select All Children"),
                                                sigc::bind(
@@ -2590,7 +2641,7 @@ CanvasView::rebuild_ducks_layer_(synfig::TransformStack& transform_stack, Canvas
 
                // If this is a paste canvas layer, then we need to
                // descend into it
-               if(layer_name=="paste_canvas")
+               if(layer_name=="PasteCanvas")
                {
                        Vector scale;
                        scale[0]=scale[1]=exp(layer->get_param("zoom").get(Real()));
@@ -2785,10 +2836,15 @@ CanvasView::play()
                if(!work_area->sync_render_preview())
                        break;
 
-               studio::App::iteration(false);
+               // wait for the workarea to refresh itself
+               while (studio::App::events_pending())
+                       studio::App::iteration(false);
 
                if(get_cancel_status())
+               {
+                       is_playing_=false;
                        return;
+               }
        }
        is_playing_=false;
 
@@ -2973,7 +3029,7 @@ CanvasView::on_waypoint_delete()
 }
 
 void
-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)
+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)
 {
        // We will make this true once we have a solid drop
        bool success(false);
@@ -3006,7 +3062,7 @@ CanvasView::on_drop_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& con
                        if(!get_instance()->perform_action(action))
                                break;
 
-                       // Ok, we have successfuly imported at least one item.
+                       // Ok, we have successfully imported at least one item.
                        success=true;
                } while(0); // END of "STRING"
 
@@ -3363,7 +3419,7 @@ CanvasView::on_audio_offset_notify()
        sound_dialog->set_offset(t);
        disp_audio->queue_draw();
 
-       synfig::info("CanvasView::on_audio_offset_notify(): offset time set to %s",t.get_string(get_canvas()->rend_desc().get_frame_rate()).c_str());
+       // synfig::info("CanvasView::on_audio_offset_notify(): offset time set to %s",t.get_string(get_canvas()->rend_desc().get_frame_rate()).c_str());
 }
 
 void