From: Carlos Lopez Date: Sat, 23 Jan 2010 09:46:38 +0000 (+0100) Subject: Merge branch 'nikitakit_ducks' X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=d615bff31f340357ef81ba7cf9855df6716e4284;hp=1a1e0c7df827bcb4b68d9781101c72a7ca64185b;p=synfig.git Merge branch 'nikitakit_ducks' --- diff --git a/synfig-studio/images/Makefile.am b/synfig-studio/images/Makefile.am index 77fac06..0d703f3 100644 --- a/synfig-studio/images/Makefile.am +++ b/synfig-studio/images/Makefile.am @@ -41,7 +41,6 @@ EXTRA_DIST = \ mirror_icon.sif \ navigator_icon.sif \ normal_icon.sif \ - null_icon.sif \ pastecanvas_icon.sif \ polygon_icon.sif \ real_icon.sif \ @@ -111,6 +110,7 @@ IMAGES = \ reset_colors_icon.$(EXT) \ swap_colors_icon.$(EXT) \ rotate_icon.$(EXT) \ + scale_icon.$(EXT) \ smooth_move_icon.$(EXT) \ width_icon.$(EXT) \ rectangle_icon.$(EXT) \ @@ -119,7 +119,6 @@ IMAGES = \ sketch_icon.$(EXT) \ fill_icon.$(EXT) \ normal_icon.$(EXT) \ - null_icon.$(EXT) \ select_all_child_layers_icon.$(EXT) \ sif_icon.$(EXT) \ synfig_icon.$(EXT) \ diff --git a/synfig-studio/images/null_icon.sif b/synfig-studio/images/null_icon.sif deleted file mode 100644 index 079b1d2..0000000 --- a/synfig-studio/images/null_icon.sif +++ /dev/null @@ -1,65 +0,0 @@ - - - Untitled0 - - - - - - - - - - - - - 0.0000000000 - 0.0500000007 - - - - - - - - - - - - - - - - - - - - - 0.000000 - 0.000000 - 0.000000 - 1.000000 - - - - - 0.1000000015 - -0.1000000015 - - - - - 0.2000000030 - 0.2000000030 - - - - - - - - - - diff --git a/synfig-studio/images/scale_icon.sif b/synfig-studio/images/scale_icon.sif new file mode 100644 index 0000000..cd3c687 --- /dev/null +++ b/synfig-studio/images/scale_icon.sif @@ -0,0 +1,3494 @@ + + + Synfig Studio Scale Icon + Placed in the Public Domain in 2007 by Chris Norman (pixelgeek) + + + + + + + + + + + + + + + + + + + -0.6717824340 + 8.4043684006 + + + + + -0.4427109957 + -1.6098945141 + + + + + + 0.064115 + 0.064115 + 0.064115 + 1.000000 + + + 1.000000 + 1.000000 + 1.000000 + 0.000000 + + + + + + + + + + + + + + -1.1483865976 + 1.7675857544 + + + + + 2.6703450680 + -2.1673052311 + + + + + -1.6225999594 + -2.2716398239 + + + + + 2.7584199905 + -2.2716398239 + + + + + 3.4074599743 + -3.0829398632 + + + + + -1.1358199120 + -3.0829398632 + + + + + + + + + + + + + + + + + + + + + + 0.011238 + 0.064115 + 0.247404 + 1.000000 + + + + + -1.8173098564 + -2.5961568356 + + + + + 3.1153881550 + 1.5576940775 + + + + + + + + + + + + + + + + + + + + + + 1.000000 + 1.000000 + 1.000000 + 1.000000 + + + + + -1.5576940775 + -2.3365411758 + + + + + 2.8557724953 + 1.2980784178 + + + + + + + + + + + + + + + + + + + + + + 0.0000000000 + 0.0000000000 + + + + + + + + + + + + + + + + + 1.000000 + 1.000000 + 1.000000 + 1.000000 + + + + + -1.2980784178 + -2.0769255161 + + + + + 2.5961568356 + 1.0384627581 + + + + + + + + + + + + + + + + + + + + + + -1.7848600149 + 1.9471199512 + + + + + 2.9206800461 + -4.0564999580 + + + + + + 0.028991 + 0.133209 + 0.374624 + 1.000000 + + + 1.000000 + 1.000000 + 1.000000 + 1.000000 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0.011238 + 0.064115 + 0.247404 + 1.000000 + + + + + -3.1153881550 + 0.2596156895 + + + + + 0.0000000000 + 2.8557724953 + + + + + + + + + + + + + + + + + + + + + + 1.000000 + 1.000000 + 1.000000 + 1.000000 + + + + + -2.8557724953 + 0.5192313790 + + + + + -0.2596156895 + 2.5961568356 + + + + + + + + + + + + + + + + + + + + + + -1.7848598957 + 1.9471199512 + + + + + + + + + + + + + + + + + 1.000000 + 1.000000 + 1.000000 + 1.000000 + + + + + -0.8112969995 + -1.1682728529 + + + + + 1.2656285763 + 0.3894212246 + + + + + + + + + + + + + + + + + + + + + + -1.7848600149 + 1.9471199512 + + + + + 2.9206800461 + -4.0564999580 + + + + + + 0.028991 + 0.133209 + 0.374624 + 1.000000 + + + 1.000000 + 1.000000 + 1.000000 + 1.000000 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -2.2769572735 + -1.7023979425 + + + + + + + + + + + + + + + + + 0.011238 + 0.064115 + 0.247404 + 1.000000 + + + + + 1.9471199512 + 0.0000000000 + + + + + + + + + + + + + + + + + + + + + -1.9471199512 + 2.2716398239 + + + + + + + + + + + + + + 0.0000000000 + 0.0000000000 + + + + + + + + + + + + + + + + + + + -1.9471199512 + 1.9471199512 + + + + + + + + + + + + + + 0.0000000000 + 0.0000000000 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0.011238 + 0.064115 + 0.247404 + 1.000000 + + + + + 1.9471199512 + 0.6490399837 + + + + + + + + + + + + + + + + + + + + + -1.9471199512 + 2.2716398239 + + + + + + + + + + + + + + 0.0000000000 + 0.0000000000 + + + + + + + + + + + + + + + + + + + -1.9471199512 + 1.9471199512 + + + + + + + + + + + + + + 0.0000000000 + 0.0000000000 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0.011238 + 0.064115 + 0.247404 + 1.000000 + + + + + 1.9471199512 + 1.2980799675 + + + + + + + + + + + + + + + + + + + + + -1.9471199512 + 2.2716398239 + + + + + + + + + + + + + + 0.0000000000 + 0.0000000000 + + + + + + + + + + + + + + + + + + + -1.9471199512 + 1.9471199512 + + + + + + + + + + + + + + 0.0000000000 + 0.0000000000 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0.011238 + 0.064115 + 0.247404 + 1.000000 + + + + + 1.9471199512 + -0.6490399837 + + + + + + + + + + + + + + + + + + + + + -1.9471199512 + 2.2716398239 + + + + + + + + + + + + + + 0.0000000000 + 0.0000000000 + + + + + + + + + + + + + + + + + + + -1.9471199512 + 1.9471199512 + + + + + + + + + + + + + + 0.0000000000 + 0.0000000000 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0.9788787961 + -1.5747181177 + + + + + + + + + + + + + + + + + 0.011238 + 0.064115 + 0.247404 + 1.000000 + + + + + 1.9471199512 + 0.0000000000 + + + + + + + + + + + + + + + + + + + + + -1.9471199512 + 2.2716398239 + + + + + + + + + + + + + + 0.0000000000 + 0.0000000000 + + + + + + + + + + + + + + + + + + + -1.9471199512 + 1.9471199512 + + + + + + + + + + + + + + 0.0000000000 + 0.0000000000 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0.011238 + 0.064115 + 0.247404 + 1.000000 + + + + + 1.9471199512 + 0.6490399837 + + + + + + + + + + + + + + + + + + + + + -1.9471199512 + 2.2716398239 + + + + + + + + + + + + + + 0.0000000000 + 0.0000000000 + + + + + + + + + + + + + + + + + + + -1.9471199512 + 1.9471199512 + + + + + + + + + + + + + + 0.0000000000 + 0.0000000000 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0.011238 + 0.064115 + 0.247404 + 1.000000 + + + + + 1.9471199512 + 1.2980799675 + + + + + + + + + + + + + + + + + + + + + -1.9471199512 + 2.2716398239 + + + + + + + + + + + + + + 0.0000000000 + 0.0000000000 + + + + + + + + + + + + + + + + + + + -1.9471199512 + 1.9471199512 + + + + + + + + + + + + + + 0.0000000000 + 0.0000000000 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0.011238 + 0.064115 + 0.247404 + 1.000000 + + + + + 1.9471199512 + -0.6490399837 + + + + + + + + + + + + + + + + + + + + + -1.9471199512 + 2.2716398239 + + + + + + + + + + + + + + 0.0000000000 + 0.0000000000 + + + + + + + + + + + + + + + + + + + -1.9471199512 + 1.9471199512 + + + + + + + + + + + + + + 0.0000000000 + 0.0000000000 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -0.0957598835 + -2.7983164787 + + + + + + + + + + + + + + + + + 0.011238 + 0.064115 + 0.247404 + 1.000000 + + + + + 2.2716398239 + 0.0000000000 + + + + + + + + + + + + + + + + + + + + + -1.9471199512 + 2.1093800068 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -1.6225999594 + 2.1093800068 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0.011238 + 0.064115 + 0.247404 + 1.000000 + + + + + 1.7848598957 + 0.0000000000 + + + + + + + + + + + + + + + + + + + + + -1.9471199512 + 2.1093800068 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -1.6225999594 + 2.1093800068 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0.011238 + 0.064115 + 0.247404 + 1.000000 + + + + + 1.2980799675 + 0.0000000000 + + + + + + + + + + + + + + + + + + + + + -1.9471199512 + 2.1093800068 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -1.6225999594 + 2.1093800068 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0.011238 + 0.064115 + 0.247404 + 1.000000 + + + + + 0.8112999797 + 0.0000000000 + + + + + + + + + + + + + + + + + + + + + -1.9471199512 + 2.1093800068 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -1.6225999594 + 2.1093800068 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0.011238 + 0.064115 + 0.247404 + 1.000000 + + + + + 0.3245199919 + 0.0000000000 + + + + + + + + + + + + + + + + + + + + + -1.9471199512 + 2.1093800068 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -1.6225999594 + 2.1093800068 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0.011238 + 0.064115 + 0.247404 + 1.000000 + + + + + -0.1622599959 + 0.0000000000 + + + + + + + + + + + + + + + + + + + + + -1.9471199512 + 2.1093800068 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -1.6225999594 + 2.1093800068 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0.0286085363 + 0.0443108305 + + + + + + + + + + + + + + + + + 0.011238 + 0.064115 + 0.247404 + 1.000000 + + + + + 2.2716398239 + 0.0000000000 + + + + + + + + + + + + + + + + + + + + + -1.9471199512 + 2.1093800068 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -1.6225999594 + 2.1093800068 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0.011238 + 0.064115 + 0.247404 + 1.000000 + + + + + 1.7848598957 + 0.0000000000 + + + + + + + + + + + + + + + + + + + + + -1.9471199512 + 2.1093800068 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -1.6225999594 + 2.1093800068 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0.011238 + 0.064115 + 0.247404 + 1.000000 + + + + + 1.2980799675 + 0.0000000000 + + + + + + + + + + + + + + + + + + + + + -1.9471199512 + 2.1093800068 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -1.6225999594 + 2.1093800068 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0.011238 + 0.064115 + 0.247404 + 1.000000 + + + + + 0.8112999797 + 0.0000000000 + + + + + + + + + + + + + + + + + + + + + -1.9471199512 + 2.1093800068 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -1.6225999594 + 2.1093800068 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0.011238 + 0.064115 + 0.247404 + 1.000000 + + + + + 0.3245199919 + 0.0000000000 + + + + + + + + + + + + + + + + + + + + + -1.9471199512 + 2.1093800068 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -1.6225999594 + 2.1093800068 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0.011238 + 0.064115 + 0.247404 + 1.000000 + + + + + -0.1622599959 + 0.0000000000 + + + + + + + + + + + + + + + + + + + + + -1.9471199512 + 2.1093800068 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -1.6225999594 + 2.1093800068 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0.011238 + 0.064115 + 0.247404 + 1.000000 + + + + + 0.0000000000 + 0.0000000000 + + + + + + + + + + + + + + + + + + + -1.7130378485 + 2.0215976238 + + + + + -2.0641574860 + 1.6385580301 + + + + + 0.7235190868 + -0.7979990244 + + + + + -0.0033114245 + -1.5410472155 + + + + + 1.8586863279 + -1.5304071903 + + + + + 1.8513576984 + 0.3191995919 + + + + + 1.0852786303 + -0.4468794465 + + + + + + + + + + + + + + + + + + 1.000000 + 1.000000 + 1.000000 + 1.000000 + + + + + 0.0000000000 + 0.0000000000 + + + + + + + + + + + + + + + + + + + -1.7236778736 + 1.7875177860 + + + + + -1.8407176733 + 1.6704779863 + + + + + 0.9682388306 + -0.7979990244 + + + + + 0.4222880602 + -1.3601673841 + + + + + 1.6990864277 + -1.3601673841 + + + + + 1.6704779863 + -0.1063998714 + + + + + 1.1065586805 + -0.6703191996 + + + + + + diff --git a/synfig-studio/src/gtkmm/Makefile.am b/synfig-studio/src/gtkmm/Makefile.am index f7fd175..c5cc73d 100644 --- a/synfig-studio/src/gtkmm/Makefile.am +++ b/synfig-studio/src/gtkmm/Makefile.am @@ -170,9 +170,10 @@ STATE_HH = \ state_fill.h \ state_gradient.h \ state_normal.h \ - state_null.h \ state_polygon.h \ state_rectangle.h \ + state_rotate.h \ + state_scale.h \ state_sketch.h \ state_smoothmove.h \ state_star.h \ @@ -189,9 +190,10 @@ STATE_CC = \ state_fill.cpp \ state_gradient.cpp \ state_normal.cpp \ - state_null.cpp \ state_polygon.cpp \ state_rectangle.cpp \ + state_rotate.cpp \ + state_scale.cpp \ state_sketch.cpp \ state_smoothmove.cpp \ state_star.cpp \ diff --git a/synfig-studio/src/gtkmm/app.cpp b/synfig-studio/src/gtkmm/app.cpp index 7bffd2c..bde450c 100644 --- a/synfig-studio/src/gtkmm/app.cpp +++ b/synfig-studio/src/gtkmm/app.cpp @@ -90,9 +90,11 @@ #include "state_circle.h" #include "state_rectangle.h" #include "state_smoothmove.h" +#include "state_scale.h" #include "state_star.h" #include "state_text.h" #include "state_width.h" +#include "state_rotate.h" #include "state_zoom.h" #include "devicetracker.h" @@ -1294,21 +1296,22 @@ App::App(int *argc, char ***argv): /* editing tools */ state_manager->add_state(&state_normal); state_manager->add_state(&state_smooth_move); + state_manager->add_state(&state_scale); + state_manager->add_state(&state_rotate); studio_init_cb.task(_("Init ModMirror...")); module_list_.push_back(new ModMirror()); module_list_.back()->start(); if(!getenv("SYNFIG_DISABLE_WIDTH" )) state_manager->add_state(&state_width); // Enabled since 0.61.09 /* new objects */ - state_manager->add_state(&state_bline); state_manager->add_state(&state_circle); state_manager->add_state(&state_rectangle); state_manager->add_state(&state_star); state_manager->add_state(&state_gradient); if(!getenv("SYNFIG_DISABLE_POLYGON")) state_manager->add_state(&state_polygon); // Enabled - for working without ducks state_manager->add_state(&state_text); + state_manager->add_state(&state_bline); if(!getenv("SYNFIG_DISABLE_DRAW" )) state_manager->add_state(&state_draw); // Enabled for now. Let's see whether they're good enough yet. /* other */ - state_manager->add_state(&state_fill); state_manager->add_state(&state_eyedrop); state_manager->add_state(&state_zoom); diff --git a/synfig-studio/src/gtkmm/canvasview.cpp b/synfig-studio/src/gtkmm/canvasview.cpp index 6c7b38a..f520ced 100644 --- a/synfig-studio/src/gtkmm/canvasview.cpp +++ b/synfig-studio/src/gtkmm/canvasview.cpp @@ -83,7 +83,6 @@ #include "dialog_color.h" #include "eventkey.h" -#include "state_null.h" #include "state_polygon.h" #include "state_bline.h" #include "state_normal.h" @@ -721,8 +720,6 @@ CanvasView::CanvasView(etl::loose_handle instance,etl::handle instance,etl::handle #include "state_mirror.h" +#include "../state_normal.h" #include "../canvasview.h" #include "../workarea.h" #include "../app.h" @@ -92,6 +93,7 @@ public: class studio::StateMirror_Context : public sigc::trackable { etl::handle canvas_view_; + CanvasView::IsWorking is_working; synfigapp::Settings& settings; @@ -122,8 +124,10 @@ public: void update_axes() { duck_dragger_->axis=get_axis(); + get_work_area()->set_cursor(get_axis() == AXIS_X?Gdk::SB_H_DOUBLE_ARROW:Gdk::SB_V_DOUBLE_ARROW); } + Smach::event_result event_stop_handler(const Smach::event& x); Smach::event_result event_refresh_tool_options(const Smach::event& x); void refresh_tool_options(); @@ -149,6 +153,7 @@ StateMirror::StateMirror(): Smach::state("mirror") { insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateMirror_Context::event_refresh_tool_options)); + insert(event_def(EVENT_STOP,&StateMirror_Context::event_stop_handler)); } StateMirror::~StateMirror() @@ -172,6 +177,7 @@ StateMirror_Context::save_settings() StateMirror_Context::StateMirror_Context(CanvasView* canvas_view): canvas_view_(canvas_view), + is_working(*canvas_view), settings(synfigapp::Main::get_selected_input_device()->settings()), duck_dragger_(new DuckDrag_Mirror()), radiobutton_axis_x(radiobutton_group,_("Horizontal")), @@ -196,8 +202,8 @@ StateMirror_Context::StateMirror_Context(CanvasView* canvas_view): keypress_connect=get_work_area()->signal_key_press_event().connect(sigc::mem_fun(*this,&StateMirror_Context::key_event),false); keyrelease_connect=get_work_area()->signal_key_release_event().connect(sigc::mem_fun(*this,&StateMirror_Context::key_event),false); -// get_canvas_view()->work_area->set_cursor(Gdk::CROSSHAIR); - get_canvas_view()->work_area->reset_cursor(); + get_work_area()->set_cursor(Gdk::SB_H_DOUBLE_ARROW); +// get_work_area()->reset_cursor(); App::toolbox->refresh(); @@ -209,7 +215,10 @@ bool StateMirror_Context::key_event(GdkEventKey *event) { if (event->keyval==GDK_Shift_L || event->keyval==GDK_Shift_R ) + { set_axis(get_axis()==AXIS_X ? AXIS_Y:AXIS_X); + get_work_area()->set_cursor(get_axis() == AXIS_X?Gdk::SB_H_DOUBLE_ARROW:Gdk::SB_V_DOUBLE_ARROW); + } return false; //Pass on the event to other handlers, just in case } @@ -230,13 +239,19 @@ StateMirror_Context::event_refresh_tool_options(const Smach::event& /*x*/) return Smach::RESULT_ACCEPT; } +Smach::event_result +StateMirror_Context::event_stop_handler(const Smach::event& /*x*/) +{ + throw &state_normal; + return Smach::RESULT_OK; +} StateMirror_Context::~StateMirror_Context() { save_settings(); get_work_area()->clear_duck_dragger(); - get_canvas_view()->work_area->reset_cursor(); + get_work_area()->reset_cursor(); keypress_connect.disconnect(); keyrelease_connect.disconnect(); diff --git a/synfig-studio/src/gtkmm/state_bline.cpp b/synfig-studio/src/gtkmm/state_bline.cpp index 7a27d84..ee0ca20 100644 --- a/synfig-studio/src/gtkmm/state_bline.cpp +++ b/synfig-studio/src/gtkmm/state_bline.cpp @@ -36,6 +36,7 @@ #include #include "state_bline.h" +#include "state_normal.h" #include "canvasview.h" #include "workarea.h" #include "app.h" @@ -205,7 +206,7 @@ public: Smach::event_result event_layer_selection_changed_handler(const Smach::event& /*x*/) { if(egress_on_selection_change) - throw Smach::egress_exception(); + throw &state_normal; //throw Smach::egress_exception(); return Smach::RESULT_OK; } @@ -408,7 +409,7 @@ StateBLine_Context::StateBLine_Context(CanvasView* canvas_view): // Connect a signal //get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateBLine_Context::on_user_click)); - get_canvas_view()->work_area->set_cursor(Gdk::CROSSHAIR); + get_work_area()->set_cursor(Gdk::CROSSHAIR); App::toolbox->refresh(); } @@ -456,7 +457,7 @@ StateBLine_Context::~StateBLine_Context() save_settings(); App::dialog_tool_options->clear(); - get_canvas_view()->work_area->reset_cursor(); + get_work_area()->reset_cursor(); // Restore layer clicking get_work_area()->set_allow_layer_clicks(prev_workarea_layer_status_); diff --git a/synfig-studio/src/gtkmm/state_circle.cpp b/synfig-studio/src/gtkmm/state_circle.cpp index fe82e21..ce155b0 100644 --- a/synfig-studio/src/gtkmm/state_circle.cpp +++ b/synfig-studio/src/gtkmm/state_circle.cpp @@ -38,6 +38,7 @@ #include #include "state_circle.h" +#include "state_normal.h" #include "canvasview.h" #include "workarea.h" #include "app.h" @@ -208,7 +209,7 @@ public: Smach::event_result event_layer_selection_changed_handler(const Smach::event& /*x*/) { if(egress_on_selection_change) - throw Smach::egress_exception(); + throw &state_normal; //throw Smach::egress_exception(); return Smach::RESULT_OK; } @@ -483,7 +484,7 @@ options_table.attach(*manage(new Gtk::Label(_("Point Angle Offset:"))), 0, 1, 14 // Connect a signal //get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateCircle_Context::on_user_click)); - get_canvas_view()->work_area->set_cursor(Gdk::CROSSHAIR); + get_work_area()->set_cursor(Gdk::CROSSHAIR); App::toolbox->refresh(); } @@ -510,7 +511,7 @@ StateCircle_Context::~StateCircle_Context() // Restore layer clicking get_work_area()->set_allow_layer_clicks(prev_workarea_layer_status_); - get_canvas_view()->work_area->reset_cursor(); + get_work_area()->reset_cursor(); App::dialog_tool_options->clear(); @@ -531,7 +532,9 @@ StateCircle_Context::~StateCircle_Context() Smach::event_result StateCircle_Context::event_stop_handler(const Smach::event& /*x*/) { - throw Smach::egress_exception(); + //throw Smach::egress_exception(); + throw &state_normal; + return Smach::RESULT_OK; } Smach::event_result diff --git a/synfig-studio/src/gtkmm/state_draw.cpp b/synfig-studio/src/gtkmm/state_draw.cpp index 4d058f2..4482045 100644 --- a/synfig-studio/src/gtkmm/state_draw.cpp +++ b/synfig-studio/src/gtkmm/state_draw.cpp @@ -38,6 +38,7 @@ #include "state_draw.h" #include "state_stroke.h" +#include "state_normal.h" #include "canvasview.h" #include "workarea.h" #include "app.h" @@ -487,7 +488,7 @@ StateDraw_Context::StateDraw_Context(CanvasView* canvas_view): // Connect a signal //get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateDraw_Context::on_user_click)); - get_canvas_view()->work_area->set_cursor(Gdk::PENCIL); + get_work_area()->set_cursor(Gdk::PENCIL); App::toolbox->refresh(); @@ -544,7 +545,7 @@ StateDraw_Context::~StateDraw_Context() get_work_area()->set_type_mask(old_duckmask); - get_canvas_view()->work_area->reset_cursor(); + get_work_area()->reset_cursor(); // Restore layer clicking get_work_area()->set_allow_layer_clicks(prev_workarea_layer_status_); @@ -567,7 +568,9 @@ StateDraw_Context::~StateDraw_Context() Smach::event_result StateDraw_Context::event_stop_handler(const Smach::event& /*x*/) { - throw Smach::egress_exception(); + //throw Smach::egress_exception(); + throw &state_normal; + return Smach::RESULT_OK; } Smach::event_result diff --git a/synfig-studio/src/gtkmm/state_eyedrop.cpp b/synfig-studio/src/gtkmm/state_eyedrop.cpp index 6fb940d..dcd57a1 100644 --- a/synfig-studio/src/gtkmm/state_eyedrop.cpp +++ b/synfig-studio/src/gtkmm/state_eyedrop.cpp @@ -30,6 +30,7 @@ #endif #include "state_eyedrop.h" +#include "state_normal.h" #include "workarea.h" #include #include "app.h" @@ -113,8 +114,10 @@ StateEyedrop_Context::~StateEyedrop_Context() Smach::event_result StateEyedrop_Context::event_stop_handler(const Smach::event& /*x*/) { - synfig::info("STATE EYEDROP: Received Stop Event"); - throw Smach::egress_exception(); + //synfig::info("STATE EYEDROP: Received Stop Event"); + //throw Smach::egress_exception(); + throw &state_normal; + return Smach::RESULT_OK; // canvas_view->get_smach().pop_state(); // return Smach::RESULT_ACCEPT; } diff --git a/synfig-studio/src/gtkmm/state_fill.cpp b/synfig-studio/src/gtkmm/state_fill.cpp index 60c929a..f4df2ba 100644 --- a/synfig-studio/src/gtkmm/state_fill.cpp +++ b/synfig-studio/src/gtkmm/state_fill.cpp @@ -30,6 +30,7 @@ #endif #include "state_fill.h" +#include "state_normal.h" #include "workarea.h" #include #include "app.h" @@ -121,7 +122,9 @@ Smach::event_result StateFill_Context::event_stop_handler(const Smach::event& /*x*/) { synfig::info("STATE FILL: Received Stop Event"); - throw Smach::egress_exception(); + //throw Smach::egress_exception(); + throw &state_normal; + return Smach::RESULT_OK; // canvas_view->get_smach().pop_state(); // return Smach::RESULT_ACCEPT; } diff --git a/synfig-studio/src/gtkmm/state_gradient.cpp b/synfig-studio/src/gtkmm/state_gradient.cpp index c8461b5..8e36214 100644 --- a/synfig-studio/src/gtkmm/state_gradient.cpp +++ b/synfig-studio/src/gtkmm/state_gradient.cpp @@ -37,6 +37,7 @@ #include #include "state_gradient.h" +#include "state_normal.h" #include "canvasview.h" #include "workarea.h" #include "app.h" @@ -144,7 +145,7 @@ public: Smach::event_result event_layer_selection_changed_handler(const Smach::event& /*x*/) { if(egress_on_selection_change) - throw Smach::egress_exception(); + throw &state_normal; //throw Smach::egress_exception(); return Smach::RESULT_OK; } @@ -297,7 +298,7 @@ StateGradient_Context::StateGradient_Context(CanvasView* canvas_view): // Turn off layer clicking get_work_area()->set_allow_layer_clicks(false); - get_canvas_view()->work_area->set_cursor(Gdk::CROSSHAIR); + get_work_area()->set_cursor(Gdk::CROSSHAIR); // clear out the ducks get_work_area()->clear_ducks(); @@ -342,7 +343,7 @@ StateGradient_Context::~StateGradient_Context() // Restore layer clicking // get_work_area()->set_allow_layer_clicks(prev_workarea_layer_status_); get_work_area()->set_allow_layer_clicks(true); - get_canvas_view()->work_area->reset_cursor(); + get_work_area()->reset_cursor(); App::dialog_tool_options->clear(); @@ -367,7 +368,9 @@ StateGradient_Context::~StateGradient_Context() Smach::event_result StateGradient_Context::event_stop_handler(const Smach::event& /*x*/) { - throw Smach::egress_exception(); + //throw Smach::egress_exception(); + throw &state_normal; + return Smach::RESULT_OK; } Smach::event_result diff --git a/synfig-studio/src/gtkmm/state_normal.cpp b/synfig-studio/src/gtkmm/state_normal.cpp index 15a7b43..c763022 100644 --- a/synfig-studio/src/gtkmm/state_normal.cpp +++ b/synfig-studio/src/gtkmm/state_normal.cpp @@ -140,9 +140,6 @@ public: void set_constrain_flag(bool x) { checkbutton_constrain.set_active(x); refresh_constrain_flag(); } void refresh_constrain_flag() { if(duck_dragger_)duck_dragger_->constrain=get_constrain_flag(); } - Smach::event_result event_refresh_tool_options(const Smach::event& x); - void refresh_tool_options(); - StateNormal_Context(CanvasView* canvas_view); ~StateNormal_Context(); @@ -158,6 +155,18 @@ public: bool key_pressed(GdkEventKey *event); bool key_released(GdkEventKey *event); + Smach::event_result event_stop_handler(const Smach::event& x); + Smach::event_result event_refresh_handler(const Smach::event& x); + Smach::event_result event_refresh_ducks_handler(const Smach::event& x); + Smach::event_result event_undo_handler(const Smach::event& x); + Smach::event_result event_redo_handler(const Smach::event& x); + Smach::event_result event_mouse_button_down_handler(const Smach::event& x); + Smach::event_result event_multiple_ducks_clicked_handler(const Smach::event& x); + Smach::event_result event_refresh_tool_options(const Smach::event& x); + void refresh_tool_options(); + Smach::event_result event_layer_click(const Smach::event& x); + + }; // END of class StateNormal_Context /* === M E T H O D S ======================================================= */ @@ -165,7 +174,16 @@ public: StateNormal::StateNormal(): Smach::state("normal") { + insert(event_def(EVENT_STOP,&StateNormal_Context::event_stop_handler)); + insert(event_def(EVENT_REFRESH,&StateNormal_Context::event_refresh_handler)); + insert(event_def(EVENT_REFRESH_DUCKS,&StateNormal_Context::event_refresh_ducks_handler)); + insert(event_def(EVENT_UNDO,&StateNormal_Context::event_undo_handler)); + insert(event_def(EVENT_REDO,&StateNormal_Context::event_redo_handler)); + insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,&StateNormal_Context::event_mouse_button_down_handler)); + insert(event_def(EVENT_WORKAREA_MULTIPLE_DUCKS_CLICKED,&StateNormal_Context::event_multiple_ducks_clicked_handler)); insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateNormal_Context::event_refresh_tool_options)); + insert(event_def(EVENT_WORKAREA_LAYER_CLICKED,&StateNormal_Context::event_layer_click)); + } StateNormal::~StateNormal() @@ -226,7 +244,7 @@ StateNormal_Context::StateNormal_Context(CanvasView* canvas_view): options_table.show_all(); refresh_tool_options(); //App::dialog_tool_options->set_widget(options_table); - App::dialog_tool_options->present(); + //App::dialog_tool_options->present(); get_work_area()->set_allow_layer_clicks(true); get_work_area()->set_duck_dragger(duck_dragger_); @@ -234,8 +252,9 @@ StateNormal_Context::StateNormal_Context(CanvasView* canvas_view): keypress_connect=get_work_area()->signal_key_press_event().connect(sigc::mem_fun(*this,&StateNormal_Context::key_pressed),false); keyrelease_connect=get_work_area()->signal_key_release_event().connect(sigc::mem_fun(*this,&StateNormal_Context::key_released),false); -// get_canvas_view()->work_area->set_cursor(Gdk::CROSSHAIR); - get_canvas_view()->work_area->reset_cursor(); + //these will segfault +// get_work_area()->set_cursor(Gdk::CROSSHAIR); +// get_work_area()->reset_cursor(); App::toolbox->refresh(); @@ -305,7 +324,7 @@ StateNormal_Context::~StateNormal_Context() save_settings(); get_work_area()->clear_duck_dragger(); - get_canvas_view()->work_area->reset_cursor(); + get_work_area()->reset_cursor(); keypress_connect.disconnect(); keyrelease_connect.disconnect(); @@ -315,14 +334,6 @@ StateNormal_Context::~StateNormal_Context() App::toolbox->refresh(); } - -Smach::event_result -StateNormal_Context::event_refresh_tool_options(const Smach::event& /*x*/) -{ - refresh_tool_options(); - return Smach::RESULT_ACCEPT; -} - DuckDrag_Combo::DuckDrag_Combo(): scale(false), rotate(false), @@ -524,3 +535,290 @@ DuckDrag_Combo::end_duck_drag(Duckmatic* duckmatic) return false; } } + +Smach::event_result +StateNormal_Context::event_refresh_tool_options(const Smach::event& /*x*/) +{ + refresh_tool_options(); + return Smach::RESULT_ACCEPT; +} + +Smach::event_result +StateNormal_Context::event_stop_handler(const Smach::event& /*x*/) +{ + // synfig::info("STATE NORMAL: Received Stop Event"); + canvas_view_->stop(); + return Smach::RESULT_ACCEPT; +} + +Smach::event_result +StateNormal_Context::event_refresh_handler(const Smach::event& /*x*/) +{ + // synfig::info("STATE NORMAL: Received Refresh Event"); + canvas_view_->rebuild_tables(); + canvas_view_->work_area->queue_render_preview(); + return Smach::RESULT_ACCEPT; +} + +Smach::event_result +StateNormal_Context::event_refresh_ducks_handler(const Smach::event& /*x*/) +{ + // synfig::info("STATE NORMAL: Received Refresh Ducks"); + canvas_view_->queue_rebuild_ducks(); + return Smach::RESULT_ACCEPT; +} + +Smach::event_result +StateNormal_Context::event_undo_handler(const Smach::event& /*x*/) +{ + // synfig::info("STATE NORMAL: Received Undo Event"); + canvas_view_->get_instance()->undo(); + return Smach::RESULT_ACCEPT; +} + +Smach::event_result +StateNormal_Context::event_redo_handler(const Smach::event& /*x*/) +{ + // synfig::info("STATE NORMAL: Received Redo Event"); + canvas_view_->get_instance()->redo(); + return Smach::RESULT_ACCEPT; +} + +Smach::event_result +StateNormal_Context::event_mouse_button_down_handler(const Smach::event& x) +{ + // synfig::info("STATE NORMAL: Received mouse button down Event"); + + const EventMouse& event(*reinterpret_cast(&x)); + + switch(event.button) + { + case BUTTON_RIGHT: + canvas_view_->popup_main_menu(); + return Smach::RESULT_ACCEPT; + default: + return Smach::RESULT_OK; + } +} + +Smach::event_result +StateNormal_Context::event_layer_click(const Smach::event& x) +{ + const EventLayerClick& event(*reinterpret_cast(&x)); + + if(event.layer) + { + // synfig::info("STATE NORMAL: Received layer click Event, \"%s\"",event.layer->get_name().c_str()); + } + else + { + // synfig::info("STATE NORMAL: Received layer click Event with an empty layer."); + } + + switch(event.button) + { + case BUTTON_LEFT: + if(!(event.modifier&Gdk::CONTROL_MASK)) + canvas_view_->get_selection_manager()->clear_selected_layers(); + if(event.layer) + { + std::list layer_list(canvas_view_->get_selection_manager()->get_selected_layers()); + std::set layers(layer_list.begin(),layer_list.end()); + if(layers.count(event.layer)) + { + layers.erase(event.layer); + layer_list=std::list(layers.begin(),layers.end()); + canvas_view_->get_selection_manager()->clear_selected_layers(); + canvas_view_->get_selection_manager()->set_selected_layers(layer_list); + } + else + { + canvas_view_->get_selection_manager()->set_selected_layer(event.layer); + } + } + return Smach::RESULT_ACCEPT; + case BUTTON_RIGHT: + canvas_view_->popup_layer_menu(event.layer); + return Smach::RESULT_ACCEPT; + default: + return Smach::RESULT_OK; + } +} + +/* +void +StateNormal_Context::edit_several_waypoints(std::list value_desc_list) +{ + Gtk::Dialog dialog( + "Edit Multiple Waypoints", // Title + true, // Modal + true // use_separator + ); + + Widget_WaypointModel widget_waypoint_model; + widget_waypoint_model.show(); + + dialog.get_vbox()->pack_start(widget_waypoint_model); + + + dialog.add_button(Gtk::StockID("gtk-apply"),1); + dialog.add_button(Gtk::StockID("gtk-cancel"),0); + dialog.show(); + + if(dialog.run()==0) + return; + synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Set Waypoints")); + + std::list::iterator iter; + for(iter=value_desc_list.begin();iter!=value_desc_list.end();++iter) + { + synfigapp::ValueDesc value_desc(*iter); + + if(!value_desc.is_valid()) + continue; + + ValueNode_Animated::Handle value_node; + + // If this value isn't a ValueNode_Animated, but + // it is somewhat constant, then go ahead and convert + // it to a ValueNode_Animated. + if(!value_desc.is_value_node() || ValueNode_Const::Handle::cast_dynamic(value_desc.get_value_node())) + { + ValueBase value; + if(value_desc.is_value_node()) + value=ValueNode_Const::Handle::cast_dynamic(value_desc.get_value_node())->get_value(); + else + value=value_desc.get_value(); + + value_node=ValueNode_Animated::create(value,get_canvas()->get_time()); + + synfigapp::Action::Handle action; + + if(!value_desc.is_value_node()) + { + action=synfigapp::Action::create("ValueDescConnect"); + action->set_param("dest",value_desc); + action->set_param("src",ValueNode::Handle(value_node)); + } + else + { + action=synfigapp::Action::create("ValueNodeReplace"); + action->set_param("dest",value_desc.get_value_node()); + action->set_param("src",ValueNode::Handle(value_node)); + } + + action->set_param("canvas",get_canvas()); + action->set_param("canvas_interface",get_canvas_interface()); + + + if(!get_canvas_interface()->get_instance()->perform_action(action)) + { + get_canvas_view()->get_ui_interface()->error(_("Unable to convert to animated waypoint")); + group.cancel(); + return; + } + } + else + { + if(value_desc.is_value_node()) + value_node=ValueNode_Animated::Handle::cast_dynamic(value_desc.get_value_node()); + } + + + if(value_node) + { + + synfigapp::Action::Handle action(synfigapp::Action::create("WaypointSetSmart")); + + if(!action) + { + get_canvas_view()->get_ui_interface()->error(_("Unable to find WaypointSetSmart action")); + group.cancel(); + return; + } + + + action->set_param("canvas",get_canvas()); + action->set_param("canvas_interface",get_canvas_interface()); + action->set_param("value_node",ValueNode::Handle(value_node)); + action->set_param("time",get_canvas()->get_time()); + action->set_param("model",widget_waypoint_model.get_waypoint_model()); + + if(!get_canvas_interface()->get_instance()->perform_action(action)) + { + get_canvas_view()->get_ui_interface()->error(_("Unable to set a specific waypoint")); + group.cancel(); + return; + } + } + else + { + //get_canvas_view()->get_ui_interface()->error(_("Unable to animate a specific valuedesc")); + //group.cancel(); + //return; + } + + } +} +*/ + +Smach::event_result +StateNormal_Context::event_multiple_ducks_clicked_handler(const Smach::event& /*x*/) +{ + // synfig::info("STATE NORMAL: Received multiple duck click event"); + + //const EventMouse& event(*reinterpret_cast(&x)); + + std::list value_desc_list; + + // Create a list of value_descs associated with selection + const DuckList selected_ducks(get_work_area()->get_selected_ducks()); + DuckList::const_iterator iter; + for(iter=selected_ducks.begin();iter!=selected_ducks.end();++iter) + { + synfigapp::ValueDesc value_desc((*iter)->get_value_desc()); + + if(!value_desc.is_valid()) + continue; + + if(value_desc.get_value_type()==ValueBase::TYPE_BLINEPOINT && value_desc.is_value_node() && ValueNode_Composite::Handle::cast_dynamic(value_desc.get_value_node())) + { + value_desc_list.push_back( + synfigapp::ValueDesc( + ValueNode_Composite::Handle::cast_dynamic(value_desc.get_value_node()) + ,ValueNode_Composite::Handle::cast_dynamic(value_desc.get_value_node()) + ->get_link_index_from_name("point") + ) + ); + } + else + value_desc_list.push_back(value_desc); + } + + Gtk::Menu *menu=manage(new Gtk::Menu()); + menu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), menu)); + + canvas_view_->get_instance()->make_param_menu(menu,canvas_view_->get_canvas(),value_desc_list); + + /* + synfigapp::Action::ParamList param_list; + param_list=get_canvas_interface()->generate_param_list(value_desc_list); + + canvas_view_->add_actions_to_menu(menu, param_list,synfigapp::Action::CATEGORY_VALUEDESC|synfigapp::Action::CATEGORY_VALUENODE); + + menu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Edit Waypoints"), + sigc::bind( + sigc::mem_fun( + *this, + &studio::StateNormal_Context::edit_several_waypoints + ), + value_desc_list + ) + )); + */ + menu->popup(3,gtk_get_current_event_time()); + + return Smach::RESULT_ACCEPT; +} + + diff --git a/synfig-studio/src/gtkmm/state_null.cpp b/synfig-studio/src/gtkmm/state_null.cpp deleted file mode 100644 index 4bbf96b..0000000 --- a/synfig-studio/src/gtkmm/state_null.cpp +++ /dev/null @@ -1,425 +0,0 @@ -/* === S Y N F I G ========================================================= */ -/*! \file state_null.cpp -** \brief Null State File -** -** $Id$ -** -** \legal -** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley -** Copyright (c) 2007, 2008 Chris Moore -** Copyright (c) 2009 Nikita Kitaev -** -** This package is free software; you can redistribute it and/or -** modify it under the terms of the GNU General Public License as -** published by the Free Software Foundation; either version 2 of -** the License, or (at your option) any later version. -** -** This package is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -** General Public License for more details. -** \endlegal -*/ -/* ========================================================================= */ - -/* === H E A D E R S ======================================================= */ - -#ifdef USING_PCH -# include "pch.h" -#else -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "state_null.h" -#include "workarea.h" -#include "event_mouse.h" -#include "event_layerclick.h" -#include "toolbox.h" -#include "dialog_tooloptions.h" -#include -#include "widget_waypointmodel.h" -#include -#include -#include -#include "canvasview.h" -#include "general.h" - -#endif - -/* === U S I N G =========================================================== */ - -using namespace std; -using namespace etl; -using namespace synfig; -using namespace studio; - -/* === M A C R O S ========================================================= */ - -/* === G L O B A L S ======================================================= */ - -StateNull studio::state_null; - -/* === C L A S S E S & S T R U C T S ======================================= */ - -class studio::StateNull_Context : public sigc::trackable -{ - CanvasView *canvas_view; - - CanvasView* get_canvas_view() { return canvas_view; } - Canvas::Handle get_canvas() { return canvas_view->get_canvas(); } - WorkArea* get_work_area() { return canvas_view->get_work_area(); } - etl::handle get_canvas_interface() { return canvas_view->canvas_interface(); } - - Gtk::Table options_table; - -public: - StateNull_Context(CanvasView *canvas_view); - ~StateNull_Context(); - - Smach::event_result event_stop_handler(const Smach::event& x); - Smach::event_result event_refresh_handler(const Smach::event& x); - Smach::event_result event_refresh_ducks_handler(const Smach::event& x); - Smach::event_result event_undo_handler(const Smach::event& x); - Smach::event_result event_redo_handler(const Smach::event& x); - Smach::event_result event_mouse_button_down_handler(const Smach::event& x); - Smach::event_result event_multiple_ducks_clicked_handler(const Smach::event& x); - Smach::event_result event_refresh_tool_options(const Smach::event& x); - Smach::event_result event_layer_click(const Smach::event& x); - - void refresh_tool_options(); -}; // END of class StateNull_Context - -/* === P R O C E D U R E S ================================================= */ - -/* === M E T H O D S ======================================================= */ - -StateNull::StateNull(): - Smach::state("null") -{ - insert(event_def(EVENT_STOP,&StateNull_Context::event_stop_handler)); - insert(event_def(EVENT_REFRESH,&StateNull_Context::event_refresh_handler)); - insert(event_def(EVENT_REFRESH_DUCKS,&StateNull_Context::event_refresh_ducks_handler)); - insert(event_def(EVENT_UNDO,&StateNull_Context::event_undo_handler)); - insert(event_def(EVENT_REDO,&StateNull_Context::event_redo_handler)); - insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,&StateNull_Context::event_mouse_button_down_handler)); - insert(event_def(EVENT_WORKAREA_MULTIPLE_DUCKS_CLICKED,&StateNull_Context::event_multiple_ducks_clicked_handler)); - insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateNull_Context::event_refresh_tool_options)); - insert(event_def(EVENT_WORKAREA_LAYER_CLICKED,&StateNull_Context::event_layer_click)); -} - -StateNull::~StateNull() -{ -} - -StateNull_Context::StateNull_Context(CanvasView *canvas_view): - canvas_view(canvas_view) -{ - // Synfig Studio's default state is initialized in the canvas view constructor - // As a result, it cannot reference canvas view or workarea when created - // Other states need to reference the workarea, - // so a null state was created to be the default - - options_table.attach(*manage(new Gtk::Label(_("Welcome to Synfig Studio"))), 0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); - options_table.show_all(); - refresh_tool_options(); -} - -StateNull_Context::~StateNull_Context() -{ -} - -void -StateNull_Context::refresh_tool_options() -{ - App::dialog_tool_options->clear(); - App::dialog_tool_options->set_widget(options_table); - App::dialog_tool_options->set_local_name(_("Welcome to Synfig Studio")); - App::dialog_tool_options->set_name("null"); -} - -Smach::event_result -StateNull_Context::event_refresh_tool_options(const Smach::event& /*x*/) -{ - refresh_tool_options(); - return Smach::RESULT_ACCEPT; -} - -Smach::event_result -StateNull_Context::event_stop_handler(const Smach::event& /*x*/) -{ - // synfig::info("STATE NULL: Received Stop Event"); - canvas_view->stop(); - return Smach::RESULT_ACCEPT; -} - -Smach::event_result -StateNull_Context::event_refresh_handler(const Smach::event& /*x*/) -{ - // synfig::info("STATE NULL: Received Refresh Event"); - canvas_view->rebuild_tables(); - canvas_view->work_area->queue_render_preview(); - return Smach::RESULT_ACCEPT; -} - -Smach::event_result -StateNull_Context::event_refresh_ducks_handler(const Smach::event& /*x*/) -{ - // synfig::info("STATE NULL: Received Refresh Ducks"); - canvas_view->queue_rebuild_ducks(); - return Smach::RESULT_ACCEPT; -} - -Smach::event_result -StateNull_Context::event_undo_handler(const Smach::event& /*x*/) -{ - // synfig::info("STATE NULL: Received Undo Event"); - canvas_view->get_instance()->undo(); - return Smach::RESULT_ACCEPT; -} - -Smach::event_result -StateNull_Context::event_redo_handler(const Smach::event& /*x*/) -{ - // synfig::info("STATE NULL: Received Redo Event"); - canvas_view->get_instance()->redo(); - return Smach::RESULT_ACCEPT; -} - -Smach::event_result -StateNull_Context::event_mouse_button_down_handler(const Smach::event& x) -{ - // synfig::info("STATE NULL: Received mouse button down Event"); - - const EventMouse& event(*reinterpret_cast(&x)); - - switch(event.button) - { - case BUTTON_RIGHT: - canvas_view->popup_main_menu(); - return Smach::RESULT_ACCEPT; - default: - return Smach::RESULT_OK; - } -} - -Smach::event_result -StateNull_Context::event_layer_click(const Smach::event& x) -{ - const EventLayerClick& event(*reinterpret_cast(&x)); - - if(event.layer) - { - // synfig::info("STATE NULL: Received layer click Event, \"%s\"",event.layer->get_name().c_str()); - } - else - { - // synfig::info("STATE NULL: Received layer click Event with an empty layer."); - } - - switch(event.button) - { - case BUTTON_LEFT: - if(!(event.modifier&Gdk::CONTROL_MASK)) - canvas_view->get_selection_manager()->clear_selected_layers(); - if(event.layer) - { - std::list layer_list(canvas_view->get_selection_manager()->get_selected_layers()); - std::set layers(layer_list.begin(),layer_list.end()); - if(layers.count(event.layer)) - { - layers.erase(event.layer); - layer_list=std::list(layers.begin(),layers.end()); - canvas_view->get_selection_manager()->clear_selected_layers(); - canvas_view->get_selection_manager()->set_selected_layers(layer_list); - } - else - { - canvas_view->get_selection_manager()->set_selected_layer(event.layer); - } - } - return Smach::RESULT_ACCEPT; - case BUTTON_RIGHT: - canvas_view->popup_layer_menu(event.layer); - return Smach::RESULT_ACCEPT; - default: - return Smach::RESULT_OK; - } -} - -/* -void -StateNull_Context::edit_several_waypoints(std::list value_desc_list) -{ - Gtk::Dialog dialog( - "Edit Multiple Waypoints", // Title - true, // Modal - true // use_separator - ); - - Widget_WaypointModel widget_waypoint_model; - widget_waypoint_model.show(); - - dialog.get_vbox()->pack_start(widget_waypoint_model); - - - dialog.add_button(Gtk::StockID("gtk-apply"),1); - dialog.add_button(Gtk::StockID("gtk-cancel"),0); - dialog.show(); - - if(dialog.run()==0) - return; - synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Set Waypoints")); - - std::list::iterator iter; - for(iter=value_desc_list.begin();iter!=value_desc_list.end();++iter) - { - synfigapp::ValueDesc value_desc(*iter); - - if(!value_desc.is_valid()) - continue; - - ValueNode_Animated::Handle value_node; - - // If this value isn't a ValueNode_Animated, but - // it is somewhat constant, then go ahead and convert - // it to a ValueNode_Animated. - if(!value_desc.is_value_node() || ValueNode_Const::Handle::cast_dynamic(value_desc.get_value_node())) - { - ValueBase value; - if(value_desc.is_value_node()) - value=ValueNode_Const::Handle::cast_dynamic(value_desc.get_value_node())->get_value(); - else - value=value_desc.get_value(); - - value_node=ValueNode_Animated::create(value,get_canvas()->get_time()); - - synfigapp::Action::Handle action; - - if(!value_desc.is_value_node()) - { - action=synfigapp::Action::create("ValueDescConnect"); - action->set_param("dest",value_desc); - action->set_param("src",ValueNode::Handle(value_node)); - } - else - { - action=synfigapp::Action::create("ValueNodeReplace"); - action->set_param("dest",value_desc.get_value_node()); - action->set_param("src",ValueNode::Handle(value_node)); - } - - action->set_param("canvas",get_canvas()); - action->set_param("canvas_interface",get_canvas_interface()); - - - if(!get_canvas_interface()->get_instance()->perform_action(action)) - { - get_canvas_view()->get_ui_interface()->error(_("Unable to convert to animated waypoint")); - group.cancel(); - return; - } - } - else - { - if(value_desc.is_value_node()) - value_node=ValueNode_Animated::Handle::cast_dynamic(value_desc.get_value_node()); - } - - - if(value_node) - { - - synfigapp::Action::Handle action(synfigapp::Action::create("WaypointSetSmart")); - - if(!action) - { - get_canvas_view()->get_ui_interface()->error(_("Unable to find WaypointSetSmart action")); - group.cancel(); - return; - } - - - action->set_param("canvas",get_canvas()); - action->set_param("canvas_interface",get_canvas_interface()); - action->set_param("value_node",ValueNode::Handle(value_node)); - action->set_param("time",get_canvas()->get_time()); - action->set_param("model",widget_waypoint_model.get_waypoint_model()); - - if(!get_canvas_interface()->get_instance()->perform_action(action)) - { - get_canvas_view()->get_ui_interface()->error(_("Unable to set a specific waypoint")); - group.cancel(); - return; - } - } - else - { - //get_canvas_view()->get_ui_interface()->error(_("Unable to animate a specific valuedesc")); - //group.cancel(); - //return; - } - - } -} -*/ - -Smach::event_result -StateNull_Context::event_multiple_ducks_clicked_handler(const Smach::event& /*x*/) -{ - // synfig::info("STATE NULL: Received multiple duck click event"); - - //const EventMouse& event(*reinterpret_cast(&x)); - - std::list value_desc_list; - - // Create a list of value_descs associated with selection - const DuckList selected_ducks(get_work_area()->get_selected_ducks()); - DuckList::const_iterator iter; - for(iter=selected_ducks.begin();iter!=selected_ducks.end();++iter) - { - synfigapp::ValueDesc value_desc((*iter)->get_value_desc()); - - if(!value_desc.is_valid()) - continue; - - if(value_desc.get_value_type()==ValueBase::TYPE_BLINEPOINT && value_desc.is_value_node() && ValueNode_Composite::Handle::cast_dynamic(value_desc.get_value_node())) - { - value_desc_list.push_back( - synfigapp::ValueDesc( - ValueNode_Composite::Handle::cast_dynamic(value_desc.get_value_node()) - ,ValueNode_Composite::Handle::cast_dynamic(value_desc.get_value_node()) - ->get_link_index_from_name("point") - ) - ); - } - else - value_desc_list.push_back(value_desc); - } - - Gtk::Menu *menu=manage(new Gtk::Menu()); - menu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), menu)); - - canvas_view->get_instance()->make_param_menu(menu,canvas_view->get_canvas(),value_desc_list); - - /* - synfigapp::Action::ParamList param_list; - param_list=get_canvas_interface()->generate_param_list(value_desc_list); - - canvas_view->add_actions_to_menu(menu, param_list,synfigapp::Action::CATEGORY_VALUEDESC|synfigapp::Action::CATEGORY_VALUENODE); - - menu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Edit Waypoints"), - sigc::bind( - sigc::mem_fun( - *this, - &studio::StateNull_Context::edit_several_waypoints - ), - value_desc_list - ) - )); - */ - menu->popup(3,gtk_get_current_event_time()); - - return Smach::RESULT_ACCEPT; -} - diff --git a/synfig-studio/src/gtkmm/state_null.h b/synfig-studio/src/gtkmm/state_null.h deleted file mode 100644 index 9923154..0000000 --- a/synfig-studio/src/gtkmm/state_null.h +++ /dev/null @@ -1,57 +0,0 @@ -/* === S Y N F I G ========================================================= */ -/*! \file state_null.h -** \brief Null State Header -** -** $Id$ -** -** \legal -** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley -** Copyright (c) 2009 Nikita Kitaev -** -** This package is free software; you can redistribute it and/or -** modify it under the terms of the GNU General Public License as -** published by the Free Software Foundation; either version 2 of -** the License, or (at your option) any later version. -** -** This package is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -** General Public License for more details. -** \endlegal -*/ -/* ========================================================================= */ - -/* === S T A R T =========================================================== */ - -#ifndef __SYNFIG_STATE_NULL_H -#define __SYNFIG_STATE_NULL_H - -/* === H E A D E R S ======================================================= */ - -#include "smach.h" - - -/* === M A C R O S ========================================================= */ - -/* === T Y P E D E F S ===================================================== */ - -/* === C L A S S E S & S T R U C T S ======================================= */ - -namespace studio { - -class StateNull_Context; - -class StateNull : public Smach::state -{ -public: - StateNull(); - ~StateNull(); -}; // END of class StateNull - -extern StateNull state_null; - -}; // END of namespace studio - -/* === E N D =============================================================== */ - -#endif diff --git a/synfig-studio/src/gtkmm/state_polygon.cpp b/synfig-studio/src/gtkmm/state_polygon.cpp index c016f1d..7c11c05 100644 --- a/synfig-studio/src/gtkmm/state_polygon.cpp +++ b/synfig-studio/src/gtkmm/state_polygon.cpp @@ -38,6 +38,7 @@ #include #include "state_polygon.h" +#include "state_normal.h" #include "canvasview.h" #include "workarea.h" #include "app.h" @@ -171,7 +172,7 @@ public: Smach::event_result event_layer_selection_changed_handler(const Smach::event& /*x*/) { if(egress_on_selection_change) - throw Smach::egress_exception(); + throw &state_normal; //throw Smach::egress_exception(); return Smach::RESULT_OK; } @@ -368,7 +369,7 @@ StatePolygon_Context::StatePolygon_Context(CanvasView* canvas_view): // Refresh the work area get_work_area()->queue_draw(); - get_canvas_view()->work_area->set_cursor(Gdk::CROSSHAIR); + get_work_area()->set_cursor(Gdk::CROSSHAIR); // Hide the tables if they are showing prev_table_status=get_canvas_view()->tables_are_visible(); @@ -430,7 +431,7 @@ StatePolygon_Context::~StatePolygon_Context() App::dialog_tool_options->clear(); - get_canvas_view()->work_area->reset_cursor(); + get_work_area()->reset_cursor(); // Enable the time bar get_canvas_view()->set_sensitive_timebar(true); @@ -899,6 +900,7 @@ void StatePolygon_Context::refresh_ducks() { get_work_area()->clear_ducks(); + get_work_area()->queue_draw(); if(polygon_point_list.empty()) return; diff --git a/synfig-studio/src/gtkmm/state_rectangle.cpp b/synfig-studio/src/gtkmm/state_rectangle.cpp index aa21c23..4f3eccb 100644 --- a/synfig-studio/src/gtkmm/state_rectangle.cpp +++ b/synfig-studio/src/gtkmm/state_rectangle.cpp @@ -38,6 +38,7 @@ #include #include "state_rectangle.h" +#include "state_normal.h" #include "canvasview.h" #include "workarea.h" #include "app.h" @@ -176,7 +177,7 @@ public: Smach::event_result event_layer_selection_changed_handler(const Smach::event& /*x*/) { if(egress_on_selection_change) - throw Smach::egress_exception(); + throw &state_normal; //throw Smach::egress_exception(); return Smach::RESULT_OK; } @@ -385,7 +386,7 @@ StateRectangle_Context::StateRectangle_Context(CanvasView* canvas_view): // Refresh the work area get_work_area()->queue_draw(); - get_canvas_view()->work_area->set_cursor(Gdk::CROSSHAIR); + get_work_area()->set_cursor(Gdk::DOTBOX); // Hide the tables if they are showing //prev_table_status=get_canvas_view()->tables_are_visible(); @@ -423,7 +424,7 @@ StateRectangle_Context::~StateRectangle_Context() // Restore layer clicking get_work_area()->set_allow_layer_clicks(prev_workarea_layer_status_); - get_canvas_view()->work_area->reset_cursor(); + get_work_area()->reset_cursor(); App::dialog_tool_options->clear(); @@ -444,7 +445,9 @@ StateRectangle_Context::~StateRectangle_Context() Smach::event_result StateRectangle_Context::event_stop_handler(const Smach::event& /*x*/) { - throw Smach::egress_exception(); + //throw Smach::egress_exception(); + throw &state_normal; + return Smach::RESULT_OK; } Smach::event_result diff --git a/synfig-studio/src/gtkmm/state_rotate.cpp b/synfig-studio/src/gtkmm/state_rotate.cpp new file mode 100644 index 0000000..5463a41 --- /dev/null +++ b/synfig-studio/src/gtkmm/state_rotate.cpp @@ -0,0 +1,398 @@ +/* === S Y N F I G ========================================================= */ +/*! \file state_rotate.cpp +** \brief Template File +** +** $Id$ +** +** \legal +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2008 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 +** published by the Free Software Foundation; either version 2 of +** the License, or (at your option) any later version. +** +** This package is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** General Public License for more details. +** \endlegal +*/ +/* ========================================================================= */ + +/* === H E A D E R S ======================================================= */ + +#ifdef USING_PCH +# include "pch.h" +#else +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include + +#include +#include + +#include "state_rotate.h" +#include "state_normal.h" +#include "canvasview.h" +#include "workarea.h" +#include "app.h" + +#include +#include "event_mouse.h" +#include "event_layerclick.h" +#include "toolbox.h" +#include "dialog_tooloptions.h" +#include +#include "duck.h" +#include +#include + +#include "general.h" + +#endif + +/* === U S I N G =========================================================== */ + +using namespace std; +using namespace etl; +using namespace synfig; +using namespace studio; + +/* === M A C R O S ========================================================= */ + +#ifndef EPSILON +#define EPSILON 0.0000001 +#endif + +/* === G L O B A L S ======================================================= */ + +StateRotate studio::state_rotate; + +/* === C L A S S E S & S T R U C T S ======================================= */ + +class DuckDrag_Rotate : public DuckDrag_Base +{ + + synfig::Vector last_rotate; + synfig::Vector drag_offset; + synfig::Vector center; + synfig::Vector snap; + + Angle original_angle; + Real original_mag; + + std::vector positions; + + + bool bad_drag; + bool move_only; + +public: + etl::handle canvas_view_; + bool use_magnitude; + DuckDrag_Rotate(); + void begin_duck_drag(Duckmatic* duckmatic, const synfig::Vector& begin); + bool end_duck_drag(Duckmatic* duckmatic); + void duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector); + + etl::handle get_canvas_interface()const{return canvas_view_->canvas_interface();} +}; + + +class studio::StateRotate_Context : public sigc::trackable +{ + etl::handle canvas_view_; + CanvasView::IsWorking is_working; + + synfigapp::Settings& settings; + + etl::handle duck_dragger_; + + Gtk::Table options_table; + + Gtk::CheckButton checkbutton_scale; + +public: + + bool get_scale_flag()const { return checkbutton_scale.get_active(); } + void set_scale_flag(bool x) { return checkbutton_scale.set_active(x); refresh_scale_flag(); } + + Smach::event_result event_stop_handler(const Smach::event& x); + Smach::event_result event_refresh_tool_options(const Smach::event& x); + + void refresh_tool_options(); + + void refresh_scale_flag() { if(duck_dragger_)duck_dragger_->use_magnitude=get_scale_flag(); } + + StateRotate_Context(CanvasView* canvas_view); + + ~StateRotate_Context(); + + const etl::handle& get_canvas_view()const{return canvas_view_;} + etl::handle get_canvas_interface()const{return canvas_view_->canvas_interface();} + synfig::Canvas::Handle get_canvas()const{return canvas_view_->get_canvas();} + WorkArea * get_work_area()const{return canvas_view_->get_work_area();} + + void load_settings(); + void save_settings(); +}; // END of class StateRotate_Context + +/* === M E T H O D S ======================================================= */ + +StateRotate::StateRotate(): + Smach::state("rotate") +{ + insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateRotate_Context::event_refresh_tool_options)); + insert(event_def(EVENT_STOP,&StateRotate_Context::event_stop_handler)); +} + +StateRotate::~StateRotate() +{ +} + +void +StateRotate_Context::load_settings() +{ + String value; + + if(settings.get_value("rotate.scale",value) && value=="0") + set_scale_flag(false); + else + set_scale_flag(true); +} + +void +StateRotate_Context::save_settings() +{ + settings.set_value("rotate.scale",get_scale_flag()?"1":"0"); +} + +StateRotate_Context::StateRotate_Context(CanvasView* canvas_view): + canvas_view_(canvas_view), + is_working(*canvas_view), + settings(synfigapp::Main::get_selected_input_device()->settings()), + duck_dragger_(new DuckDrag_Rotate()), + checkbutton_scale(_("Allow Scale")) +{ + duck_dragger_->canvas_view_=get_canvas_view(); + + // Set up the tool options dialog + options_table.attach(*manage(new Gtk::Label(_("Rotate Tool"))), 0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); + options_table.attach(checkbutton_scale, 0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); + + checkbutton_scale.signal_toggled().connect(sigc::mem_fun(*this,&StateRotate_Context::refresh_scale_flag)); + + options_table.show_all(); + refresh_tool_options(); + //App::dialog_tool_options->set_widget(options_table); + App::dialog_tool_options->present(); + + get_work_area()->set_allow_layer_clicks(true); + get_work_area()->set_duck_dragger(duck_dragger_); + + get_work_area()->set_cursor(Gdk::EXCHANGE); +// get_work_area()->reset_cursor(); + + App::toolbox->refresh(); + + load_settings(); + refresh_scale_flag(); +} + +void +StateRotate_Context::refresh_tool_options() +{ + App::dialog_tool_options->clear(); + App::dialog_tool_options->set_widget(options_table); + App::dialog_tool_options->set_local_name(_("Rotate Tool")); + App::dialog_tool_options->set_name("rotate"); +} + +Smach::event_result +StateRotate_Context::event_refresh_tool_options(const Smach::event& /*x*/) +{ + refresh_tool_options(); + return Smach::RESULT_ACCEPT; +} + +Smach::event_result +StateRotate_Context::event_stop_handler(const Smach::event& /*x*/) +{ + throw &state_normal; + return Smach::RESULT_OK; +} + +StateRotate_Context::~StateRotate_Context() +{ + save_settings(); + + get_work_area()->clear_duck_dragger(); + get_work_area()->reset_cursor(); + + App::dialog_tool_options->clear(); + + App::toolbox->refresh(); +} + + + + +DuckDrag_Rotate::DuckDrag_Rotate() +{ + use_magnitude=true; +} + +void +DuckDrag_Rotate::begin_duck_drag(Duckmatic* duckmatic, const synfig::Vector& offset) +{ + last_rotate=Vector(1,1); + + const DuckList selected_ducks(duckmatic->get_selected_ducks()); + DuckList::const_iterator iter; + +/* + if(duckmatic->get_selected_ducks().size()<2) + { + bad_drag=true; + return; + } +*/ + bad_drag=false; + + drag_offset=duckmatic->find_duck(offset)->get_trans_point(); + + //snap=drag_offset-duckmatic->snap_point_to_grid(drag_offset); + //snap=offset-drag_offset; + snap=Vector(0,0); + + // Calculate center + Point vmin(100000000,100000000); + Point vmax(-100000000,-100000000); + //std::set >::iterator iter; + positions.clear(); + int i; + for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++) + { + Point p((*iter)->get_trans_point()); + vmin[0]=min(vmin[0],p[0]); + vmin[1]=min(vmin[1],p[1]); + vmax[0]=max(vmax[0],p[0]); + vmax[1]=max(vmax[1],p[1]); + positions.push_back(p); + } + center=(vmin+vmax)*0.5; + if((vmin-vmax).mag()<=EPSILON) + move_only=true; + else + move_only=false; + + + synfig::Vector vect(offset-center); + original_angle=Angle::tan(vect[1],vect[0]); + original_mag=vect.mag(); +} + + +void +DuckDrag_Rotate::duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector) +{ + if(bad_drag) + return; + + //std::set >::iterator iter; + synfig::Vector vect(duckmatic->snap_point_to_grid(vector)-center+snap); + + const DuckList selected_ducks(duckmatic->get_selected_ducks()); + DuckList::const_iterator iter; + + if(move_only) + { + int i; + for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++) + { + if((*iter)->get_type()!=Duck::TYPE_VERTEX&&(*iter)->get_type()!=Duck::TYPE_POSITION)continue; + + Vector p(positions[i]); + + p[0]+=vect[0]; + p[1]+=vect[1]; + (*iter)->set_trans_point(p); + } + for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++) + { + if(!((*iter)->get_type()!=Duck::TYPE_VERTEX&&(*iter)->get_type()!=Duck::TYPE_POSITION))continue; + + Vector p(positions[i]); + + p[0]+=vect[0]; + p[1]+=vect[1]; + (*iter)->set_trans_point(p); + } + return; + } + + Angle::tan angle(vect[1],vect[0]); + angle=original_angle-angle; + Real mag(vect.mag()/original_mag); + Real sine(Angle::sin(angle).get()); + Real cosine(Angle::cos(angle).get()); + + int i; + for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++) + { + if((*iter)->get_type()!=Duck::TYPE_VERTEX&&(*iter)->get_type()!=Duck::TYPE_POSITION)continue; + + Vector x(positions[i]-center),p; + + p[0]=cosine*x[0]+sine*x[1]; + p[1]=-sine*x[0]+cosine*x[1]; + if(use_magnitude)p*=mag; + p+=center; + (*iter)->set_trans_point(p); + } + for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++) + { + if(!((*iter)->get_type()!=Duck::TYPE_VERTEX&&(*iter)->get_type()!=Duck::TYPE_POSITION))continue; + + Vector x(positions[i]-center),p; + + p[0]=cosine*x[0]+sine*x[1]; + p[1]=-sine*x[0]+cosine*x[1]; + if(use_magnitude)p*=mag; + p+=center; + (*iter)->set_trans_point(p); + } + + last_rotate=vect; + //snap=Vector(0,0); +} + +bool +DuckDrag_Rotate::end_duck_drag(Duckmatic* duckmatic) +{ + if(bad_drag)return false; + if(move_only) + { + synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Move Duck")); + duckmatic->signal_edited_selected_ducks(); + return true; + } + + synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Rotate Ducks")); + + if((last_rotate-Vector(1,1)).mag()>0.0001) + { + duckmatic->signal_edited_selected_ducks(); + return true; + } + else + { + duckmatic->signal_user_click_selected_ducks(0); + return false; + } +} diff --git a/synfig-studio/src/gtkmm/state_rotate.h b/synfig-studio/src/gtkmm/state_rotate.h new file mode 100644 index 0000000..e2caafe --- /dev/null +++ b/synfig-studio/src/gtkmm/state_rotate.h @@ -0,0 +1,56 @@ +/* === S Y N F I G ========================================================= */ +/*! \file state_rotate.h +** \brief Template Header +** +** $Id$ +** +** \legal +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** +** This package is free software; you can redistribute it and/or +** modify it under the terms of the GNU General Public License as +** published by the Free Software Foundation; either version 2 of +** the License, or (at your option) any later version. +** +** This package is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** General Public License for more details. +** \endlegal +*/ +/* ========================================================================= */ + +/* === S T A R T =========================================================== */ + +#ifndef __SYNFIG_STUDIO_STATE_ROTATE_H +#define __SYNFIG_STUDIO_STATE_ROTATE_H + +/* === H E A D E R S ======================================================= */ + +#include "smach.h" + + +/* === M A C R O S ========================================================= */ + +/* === T Y P E D E F S ===================================================== */ + +/* === C L A S S E S & S T R U C T S ======================================= */ + +namespace studio { + +class StateRotate_Context; + +class StateRotate : public Smach::state +{ +public: + StateRotate(); + ~StateRotate(); +}; // END of class StateRotate + +extern StateRotate state_rotate; + +}; // END of namespace studio + +/* === E N D =============================================================== */ + +#endif diff --git a/synfig-studio/src/gtkmm/state_scale.cpp b/synfig-studio/src/gtkmm/state_scale.cpp new file mode 100644 index 0000000..edfb89b --- /dev/null +++ b/synfig-studio/src/gtkmm/state_scale.cpp @@ -0,0 +1,389 @@ +/* === S Y N F I G ========================================================= */ +/*! \file state_scale.cpp +** \brief Template File +** +** $Id$ +** +** \legal +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2008 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 +** published by the Free Software Foundation; either version 2 of +** the License, or (at your option) any later version. +** +** This package is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** General Public License for more details. +** \endlegal +*/ +/* ========================================================================= */ + +/* === H E A D E R S ======================================================= */ + +#ifdef USING_PCH +# include "pch.h" +#else +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include + +#include +#include + +#include "state_scale.h" +#include "state_normal.h" +#include "canvasview.h" +#include "workarea.h" +#include "app.h" + +#include +#include "event_mouse.h" +#include "event_layerclick.h" +#include "toolbox.h" +#include "dialog_tooloptions.h" +#include +#include "duck.h" +#include + +#include "general.h" + +#endif + +/* === U S I N G =========================================================== */ + +using namespace std; +using namespace etl; +using namespace synfig; +using namespace studio; + +/* === M A C R O S ========================================================= */ + +/* === G L O B A L S ======================================================= */ + +StateScale studio::state_scale; + +/* === C L A S S E S & S T R U C T S ======================================= */ + +class DuckDrag_Scale : public DuckDrag_Base +{ + + synfig::Vector last_scale; + synfig::Vector drag_offset; + synfig::Vector center; + synfig::Vector snap; + + std::vector positions; + + bool move_only; + + bool bad_drag; +public: + bool lock_aspect; + DuckDrag_Scale(); + void begin_duck_drag(Duckmatic* duckmatic, const synfig::Vector& begin); + bool end_duck_drag(Duckmatic* duckmatic); + void duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector); +}; + + +class studio::StateScale_Context : public sigc::trackable +{ + etl::handle canvas_view_; + CanvasView::IsWorking is_working; + + synfigapp::Settings& settings; + + etl::handle duck_dragger_; + + Gtk::Table options_table; + + + Gtk::CheckButton checkbutton_aspect_lock; + +public: + + bool get_aspect_lock_flag()const { return checkbutton_aspect_lock.get_active(); } + void set_aspect_lock_flag(bool x) { return checkbutton_aspect_lock.set_active(x); refresh_aspect_lock_flag(); } + + void refresh_aspect_lock_flag() { if(duck_dragger_)duck_dragger_->lock_aspect=get_aspect_lock_flag(); } + + Smach::event_result event_stop_handler(const Smach::event& x); + Smach::event_result event_refresh_tool_options(const Smach::event& x); + + void refresh_tool_options(); + + StateScale_Context(CanvasView* canvas_view); + + ~StateScale_Context(); + + const etl::handle& get_canvas_view()const{return canvas_view_;} + etl::handle get_canvas_interface()const{return canvas_view_->canvas_interface();} + synfig::Canvas::Handle get_canvas()const{return canvas_view_->get_canvas();} + WorkArea * get_work_area()const{return canvas_view_->get_work_area();} + + void load_settings(); + void save_settings(); +}; // END of class StateScale_Context + +/* === M E T H O D S ======================================================= */ + +StateScale::StateScale(): + Smach::state("scale") +{ + insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateScale_Context::event_refresh_tool_options)); + insert(event_def(EVENT_STOP,&StateScale_Context::event_stop_handler)); +} + +StateScale::~StateScale() +{ +} + +void +StateScale_Context::load_settings() +{ + String value; + + if(settings.get_value("scale.lock_aspect",value) && value=="0") + set_aspect_lock_flag(false); + else + set_aspect_lock_flag(true); +} + +void +StateScale_Context::save_settings() +{ + settings.set_value("scale.lock_aspect",get_aspect_lock_flag()?"1":"0"); +} + +StateScale_Context::StateScale_Context(CanvasView* canvas_view): + canvas_view_(canvas_view), + is_working(*canvas_view), + settings(synfigapp::Main::get_selected_input_device()->settings()), + duck_dragger_(new DuckDrag_Scale()), + checkbutton_aspect_lock(_("Lock Aspect Ratio")) +{ + // Set up the tool options dialog + options_table.attach(*manage(new Gtk::Label(_("Scale Tool"))), 0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); + options_table.attach(checkbutton_aspect_lock, 0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); + + checkbutton_aspect_lock.signal_toggled().connect(sigc::mem_fun(*this,&StateScale_Context::refresh_aspect_lock_flag)); + + options_table.show_all(); + refresh_tool_options(); + App::dialog_tool_options->present(); + + get_work_area()->set_allow_layer_clicks(true); + get_work_area()->set_duck_dragger(duck_dragger_); + + get_work_area()->set_cursor(Gdk::SIZING); +// get_work_area()->reset_cursor(); + + App::toolbox->refresh(); + + set_aspect_lock_flag(true); + load_settings(); +} + +void +StateScale_Context::refresh_tool_options() +{ + App::dialog_tool_options->clear(); + App::dialog_tool_options->set_widget(options_table); + App::dialog_tool_options->set_local_name(_("Scale Tool")); + App::dialog_tool_options->set_name("scale"); +} + +Smach::event_result +StateScale_Context::event_refresh_tool_options(const Smach::event& /*x*/) +{ + refresh_tool_options(); + return Smach::RESULT_ACCEPT; +} + +Smach::event_result +StateScale_Context::event_stop_handler(const Smach::event& /*x*/) +{ + throw &state_normal; + return Smach::RESULT_OK; +} + +StateScale_Context::~StateScale_Context() +{ + save_settings(); + + get_work_area()->clear_duck_dragger(); + get_work_area()->reset_cursor(); + + App::dialog_tool_options->clear(); + + App::toolbox->refresh(); +} + + + + +DuckDrag_Scale::DuckDrag_Scale(): + lock_aspect(true) +{ +} + +#ifndef EPSILON +#define EPSILON 0.0000001 +#endif + +void +DuckDrag_Scale::begin_duck_drag(Duckmatic* duckmatic, const synfig::Vector& offset) +{ + last_scale=Vector(1,1); + const DuckList selected_ducks(duckmatic->get_selected_ducks()); + DuckList::const_iterator iter; + + //if(duckmatic->get_selected_ducks().size()<2) + //{ + // bad_drag=true; +// return; +// } + bad_drag=false; + + drag_offset=duckmatic->find_duck(offset)->get_trans_point(); + + //snap=drag_offset-duckmatic->snap_point_to_grid(drag_offset); + //snap=offset-drag_offset; + snap=Vector(0,0); + + // Calculate center + Point vmin(100000000,100000000); + Point vmax(-100000000,-100000000); + //std::set >::iterator iter; + positions.clear(); + int i; + for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++) + { + Point p((*iter)->get_trans_point()); + vmin[0]=min(vmin[0],p[0]); + vmin[1]=min(vmin[1],p[1]); + vmax[0]=max(vmax[0],p[0]); + vmax[1]=max(vmax[1],p[1]); + positions.push_back(p); + } + if((vmin-vmax).mag()<=EPSILON) + move_only=true; + else + move_only=false; + + center=(vmin+vmax)*0.5; +} + + +void +DuckDrag_Scale::duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector) +{ + const DuckList selected_ducks(duckmatic->get_selected_ducks()); + DuckList::const_iterator iter; + + if(bad_drag) + return; + + //std::set >::iterator iter; + synfig::Vector vect(duckmatic->snap_point_to_grid(vector)-center); + last_scale=vect; + + if(move_only) + { + int i; + for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++) + { + if(((*iter)->get_type()!=Duck::TYPE_VERTEX&&(*iter)->get_type()!=Duck::TYPE_POSITION))continue; + + Vector p(positions[i]); + + p[0]+=vect[0]; + p[1]+=vect[1]; + (*iter)->set_trans_point(p); + } + for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++) + { + if(!((*iter)->get_type()!=Duck::TYPE_VERTEX&&(*iter)->get_type()!=Duck::TYPE_POSITION))continue; + + Vector p(positions[i]); + + p[0]+=vect[0]; + p[1]+=vect[1]; + (*iter)->set_trans_point(p); + } + return; + } + + if(!lock_aspect) + { + if(abs(drag_offset[0]-center[0])>EPSILON) + vect[0]/=drag_offset[0]-center[0]; + else + vect[0]=1; + if(abs(drag_offset[1]-center[1])>EPSILON) + vect[1]/=drag_offset[1]-center[1]; + else + vect[1]=1; + } + else + { + //vect[0]=vect[1]=vect.mag()*0.707106781; + Real amount(vect.mag()/(drag_offset-center).mag()); + vect[0]=vect[1]=amount; + } + + if(vect[0]-EPSILON) + vect[0]=1; + if(vect[1]-EPSILON) + vect[1]=1; + + int i; + for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++) + { + if(((*iter)->get_type()!=Duck::TYPE_VERTEX&&(*iter)->get_type()!=Duck::TYPE_POSITION))continue; + + Vector p(positions[i]-center); + + p[0]*=vect[0]; + p[1]*=vect[1]; + p+=center; + (*iter)->set_trans_point(p); + } + for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++) + { + if(!((*iter)->get_type()!=Duck::TYPE_VERTEX&&(*iter)->get_type()!=Duck::TYPE_POSITION))continue; + + Vector p(positions[i]-center); + + p[0]*=vect[0]; + p[1]*=vect[1]; + p+=center; + (*iter)->set_trans_point(p); + } + + last_scale=vect; + //snap=Vector(0,0); +} + +bool +DuckDrag_Scale::end_duck_drag(Duckmatic* duckmatic) +{ + if(bad_drag)return false; + + if((last_scale-Vector(1,1)).mag()>0.0001) + { + duckmatic->signal_edited_selected_ducks(); + return true; + } + else + { + duckmatic->signal_user_click_selected_ducks(0); + return false; + } +} diff --git a/synfig-studio/src/gtkmm/state_scale.h b/synfig-studio/src/gtkmm/state_scale.h new file mode 100644 index 0000000..f351c12 --- /dev/null +++ b/synfig-studio/src/gtkmm/state_scale.h @@ -0,0 +1,55 @@ +/* === S Y N F I G ========================================================= */ +/*! \file state_scale.h +** \brief Template Header +** +** $Id$ +** +** \legal +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** +** This package is free software; you can redistribute it and/or +** modify it under the terms of the GNU General Public License as +** published by the Free Software Foundation; either version 2 of +** the License, or (at your option) any later version. +** +** This package is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** General Public License for more details. +** \endlegal +*/ +/* ========================================================================= */ + +/* === S T A R T =========================================================== */ + +#ifndef __SYNFIG_STUDIO_STATE_SCALE_H +#define __SYNFIG_STUDIO_STATE_SCALE_H + +/* === H E A D E R S ======================================================= */ + +#include "smach.h" + +/* === M A C R O S ========================================================= */ + +/* === T Y P E D E F S ===================================================== */ + +/* === C L A S S E S & S T R U C T S ======================================= */ + +namespace studio { + +class StateScale_Context; + +class StateScale : public Smach::state +{ +public: + StateScale(); + ~StateScale(); +}; // END of class StateScale + +extern StateScale state_scale; + +}; // END of namespace studio + +/* === E N D =============================================================== */ + +#endif diff --git a/synfig-studio/src/gtkmm/state_sketch.cpp b/synfig-studio/src/gtkmm/state_sketch.cpp index b0d78f0..f8b77a3 100644 --- a/synfig-studio/src/gtkmm/state_sketch.cpp +++ b/synfig-studio/src/gtkmm/state_sketch.cpp @@ -36,6 +36,7 @@ #include #include "state_sketch.h" +#include "state_normal.h" #include "state_stroke.h" #include "canvasview.h" #include "workarea.h" @@ -336,7 +337,7 @@ StateSketch_Context::StateSketch_Context(CanvasView* canvas_view): // Turn off layer clicking get_work_area()->set_allow_layer_clicks(false); - get_canvas_view()->work_area->set_cursor(Gdk::PENCIL); + get_work_area()->set_cursor(Gdk::PENCIL); // Turn off duck clicking get_work_area()->set_allow_duck_clicks(false); @@ -362,7 +363,7 @@ StateSketch_Context::StateSketch_Context(CanvasView* canvas_view): StateSketch_Context::~StateSketch_Context() { - get_canvas_view()->work_area->reset_cursor(); + get_work_area()->reset_cursor(); App::dialog_tool_options->clear(); @@ -465,7 +466,9 @@ StateSketch_Context::event_yield_tool_options(const Smach::event& /*x*/) Smach::event_result StateSketch_Context::event_stop_handler(const Smach::event& /*x*/) { - throw Smach::egress_exception(); + //throw Smach::egress_exception(); + throw &state_normal; + return Smach::RESULT_OK; } Smach::event_result diff --git a/synfig-studio/src/gtkmm/state_smoothmove.cpp b/synfig-studio/src/gtkmm/state_smoothmove.cpp index 85442cf..f42df35 100644 --- a/synfig-studio/src/gtkmm/state_smoothmove.cpp +++ b/synfig-studio/src/gtkmm/state_smoothmove.cpp @@ -40,6 +40,7 @@ #include #include "state_smoothmove.h" +#include "state_normal.h" #include "canvasview.h" #include "workarea.h" #include "app.h" @@ -98,6 +99,7 @@ public: class studio::StateSmoothMove_Context : public sigc::trackable { etl::handle canvas_view_; + CanvasView::IsWorking is_working; //Duckmatic::Push duckmatic_push; @@ -143,6 +145,7 @@ StateSmoothMove::StateSmoothMove(): Smach::state("smooth_move") { insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateSmoothMove_Context::event_refresh_tool_options)); + insert(event_def(EVENT_STOP,&StateSmoothMove_Context::event_stop_handler)); } StateSmoothMove::~StateSmoothMove() @@ -168,6 +171,7 @@ StateSmoothMove_Context::save_settings() StateSmoothMove_Context::StateSmoothMove_Context(CanvasView* canvas_view): canvas_view_(canvas_view), + is_working(*canvas_view), // duckmatic_push(get_work_area()), settings(synfigapp::Main::get_selected_input_device()->settings()), duck_dragger_(new DuckDrag_SmoothMove()), @@ -193,8 +197,8 @@ StateSmoothMove_Context::StateSmoothMove_Context(CanvasView* canvas_view): App::toolbox->refresh(); -// get_canvas_view()->work_area->set_cursor(Gdk::CROSSHAIR); - get_canvas_view()->work_area->reset_cursor(); + get_work_area()->set_cursor(Gdk::FLEUR); + //get_work_area()->reset_cursor(); load_settings(); } @@ -215,12 +219,19 @@ StateSmoothMove_Context::event_refresh_tool_options(const Smach::event& /*x*/) return Smach::RESULT_ACCEPT; } +Smach::event_result +StateSmoothMove_Context::event_stop_handler(const Smach::event& /*x*/) +{ + throw &state_normal; + return Smach::RESULT_OK; +} + StateSmoothMove_Context::~StateSmoothMove_Context() { save_settings(); get_work_area()->clear_duck_dragger(); - get_canvas_view()->work_area->reset_cursor(); + get_work_area()->reset_cursor(); App::dialog_tool_options->clear(); diff --git a/synfig-studio/src/gtkmm/state_star.cpp b/synfig-studio/src/gtkmm/state_star.cpp index e5b3ace..270571a 100644 --- a/synfig-studio/src/gtkmm/state_star.cpp +++ b/synfig-studio/src/gtkmm/state_star.cpp @@ -38,6 +38,7 @@ #include #include "state_star.h" +#include "state_normal.h" #include "canvasview.h" #include "workarea.h" #include "app.h" @@ -215,7 +216,7 @@ public: Smach::event_result event_layer_selection_changed_handler(const Smach::event& /*x*/) { if(egress_on_selection_change) - throw Smach::egress_exception(); + throw &state_normal; //throw Smach::egress_exception(); return Smach::RESULT_OK; } @@ -510,7 +511,7 @@ StateStar_Context::StateStar_Context(CanvasView* canvas_view): // Connect a signal //get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateStar_Context::on_user_click)); - get_canvas_view()->work_area->set_cursor(Gdk::CROSSHAIR); + get_work_area()->set_cursor(Gdk::STAR); App::toolbox->refresh(); } @@ -537,7 +538,7 @@ StateStar_Context::~StateStar_Context() // Restore layer clicking get_work_area()->set_allow_layer_clicks(prev_workarea_layer_status_); - get_canvas_view()->work_area->reset_cursor(); + get_work_area()->reset_cursor(); App::dialog_tool_options->clear(); @@ -558,7 +559,9 @@ StateStar_Context::~StateStar_Context() Smach::event_result StateStar_Context::event_stop_handler(const Smach::event& /*x*/) { - throw Smach::egress_exception(); + //throw Smach::egress_exception(); + throw &state_normal; + return Smach::RESULT_OK; } Smach::event_result diff --git a/synfig-studio/src/gtkmm/state_text.cpp b/synfig-studio/src/gtkmm/state_text.cpp index 8f7d0c9..f475420 100644 --- a/synfig-studio/src/gtkmm/state_text.cpp +++ b/synfig-studio/src/gtkmm/state_text.cpp @@ -34,6 +34,7 @@ #include #include "state_text.h" +#include "state_normal.h" #include "canvasview.h" #include "workarea.h" #include "app.h" @@ -132,7 +133,7 @@ public: Smach::event_result event_layer_selection_changed_handler(const Smach::event& /*x*/) { if(egress_on_selection_change) - throw Smach::egress_exception(); + throw &state_normal; //throw Smach::egress_exception(); return Smach::RESULT_OK; } @@ -316,7 +317,7 @@ StateText_Context::StateText_Context(CanvasView *canvas_view): // Connect a signal //get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateText_Context::on_user_click)); - get_canvas_view()->work_area->set_cursor(Gdk::CROSSHAIR); + get_work_area()->set_cursor(Gdk::XTERM); App::toolbox->refresh(); } @@ -343,7 +344,7 @@ StateText_Context::~StateText_Context() // Restore layer clicking get_work_area()->set_allow_layer_clicks(prev_workarea_layer_status_); - get_canvas_view()->work_area->reset_cursor(); + get_work_area()->reset_cursor(); App::dialog_tool_options->clear(); @@ -357,7 +358,9 @@ StateText_Context::~StateText_Context() Smach::event_result StateText_Context::event_stop_handler(const Smach::event& /*x*/) { - throw Smach::egress_exception(); + //throw Smach::egress_exception(); + throw &state_normal; + return Smach::RESULT_OK; } Smach::event_result diff --git a/synfig-studio/src/gtkmm/state_width.cpp b/synfig-studio/src/gtkmm/state_width.cpp index 1c7ef4f..8c74daa 100644 --- a/synfig-studio/src/gtkmm/state_width.cpp +++ b/synfig-studio/src/gtkmm/state_width.cpp @@ -39,6 +39,7 @@ #include #include "state_width.h" +#include "state_normal.h" #include "canvasview.h" #include "workarea.h" #include "app.h" @@ -356,7 +357,9 @@ StateWidth_Context::~StateWidth_Context() Smach::event_result StateWidth_Context::event_stop_handler(const Smach::event& /*x*/) { - throw Smach::egress_exception(); + //throw Smach::egress_exception(); + throw &state_normal; + return Smach::RESULT_OK; } Smach::event_result diff --git a/synfig-studio/src/gtkmm/state_zoom.cpp b/synfig-studio/src/gtkmm/state_zoom.cpp index 57a2522..56363e6 100644 --- a/synfig-studio/src/gtkmm/state_zoom.cpp +++ b/synfig-studio/src/gtkmm/state_zoom.cpp @@ -38,6 +38,7 @@ #include "state_zoom.h" +#include "state_normal.h" #include "event_mouse.h" #include "canvasview.h" #include "workarea.h" @@ -136,7 +137,7 @@ StateZoom_Context::StateZoom_Context(CanvasView* canvas_view): // Connect a signal //get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateZoom_Context::on_user_click)); - get_canvas_view()->work_area->set_cursor(Gdk::CROSSHAIR); + get_work_area()->set_cursor(Gdk::CROSSHAIR); App::toolbox->refresh(); } @@ -145,7 +146,7 @@ StateZoom_Context::~StateZoom_Context() { // Restore layer clicking get_work_area()->set_allow_layer_clicks(prev_workarea_layer_status_); - get_canvas_view()->work_area->reset_cursor(); + get_work_area()->reset_cursor(); // Enable the time bar //get_canvas_view()->set_sensitive_timebar(true); @@ -164,7 +165,9 @@ StateZoom_Context::~StateZoom_Context() Smach::event_result StateZoom_Context::event_stop_handler(const Smach::event& /*x*/) { - throw Smach::egress_exception(); + //throw Smach::egress_exception(); + throw &state_normal; + return Smach::RESULT_OK; } Smach::event_result